Habitat: pkgPathFor writes error msg when there is integer in ServiceConfig

Created on 10 Apr 2017  路  3Comments  路  Source: habitat-sh/habitat

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.

Supervisor Bug

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_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.

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings