When using {{pkgPathFor}} the error msg
shield-agent.default(HK): Failed to compile init hook: hab-sup(ER)[src/error.rs:349:8]: Error rendering "hook" line 19, col 7: "pkgPathFor" can only be used on a template bound to a service config.
is being thrown.
After debugging this a bit the issue is actually only due to a problem deserializing integers. The hook is getting rendered correctly even though the error is being displayed.
This is the printout of the error comming from this line.
hab-sup(TP): Deserialize error: Syntax(Message("invalid type: integer8080, expected any valid TOML value"), 0, 0)
the value in the context struct is:
"cfg": Object({"port": Number(PosInt(8080))}),...
https://github.com/habitat-sh/habitat/pull/1788 mentions there being an issue in regards to deserializing integers but says bumping to serde 0.9.x should fix it. By now serde has been updated but the issue remains.
Perhaps @smurawski has some insight?
For now a workaround seems to be to use strings instead of integers in config.
We did a bit of debugging/exploration and have a test that reproduces this behavior. I'm going to change our approach pkg_path_for is using and rather than hydrating this large complex ServiceConfig struct, traverse the JSON::value to the PackageInstall struct and hydrate just that (since that's the minimum we need to get the information that the helper needs.
Closed by #2077
Most helpful comment
We did a bit of debugging/exploration and have a test that reproduces this behavior. I'm going to change our approach
pkg_path_foris using and rather than hydrating this large complex ServiceConfig struct, traverse the JSON::value to thePackageInstallstruct and hydrate just that (since that's the minimum we need to get the information that the helper needs.