{"action":"created","issue":{"url":"https://api.github.com/repos/habitat-sh/habitat/issues/2947","repository_url":"https://api.github.com/repos/habitat-sh/habitat","labels_url":"https://api.github.com/repos/habitat-sh/habitat/issues/2947/labels{/name}","comments_url":"https://api.github.com/repos/habitat-sh/habitat/issues/2947/comments","events_url":"https://api.github.com/repos/habitat-sh/habitat/issues/2947/events","html_url":"https://github.com/habitat-sh/habitat/issues/2947","id":250637532,"number":2947,"title":"JSON config with integer values isn't understood","user":{"login":"srenatus","id":870638,"avatar_url":"https://avatars3.githubusercontent.com/u/870638?v=4","gravatar_id":"","url":"https://api.github.com/users/srenatus","html_url":"https://github.com/srenatus","followers_url":"https://api.github.com/users/srenatus/followers","following_url":"https://api.github.com/users/srenatus/following{/other_user}","gists_url":"https://api.github.com/users/srenatus/gists{/gist_id}","starred_url":"https://api.github.com/users/srenatus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srenatus/subscriptions","organizations_url":"https://api.github.com/users/srenatus/orgs","repos_url":"https://api.github.com/users/srenatus/repos","events_url":"https://api.github.com/users/srenatus/events{/privacy}","received_events_url":"https://api.github.com/users/srenatus/received_events","type":"User","site_admin":false},"labels":[{"id":621112519,"url":"https://api.github.com/repos/habitat-sh/habitat/labels/A-supervisor","name":"A-supervisor","color":"87B09A","default":false},{"id":621117263,"url":"https://api.github.com/repos/habitat-sh/habitat/labels/C-bug","name":"C-bug","color":"ff9012","default":false},{"id":621119774,"url":"https://api.github.com/repos/habitat-sh/habitat/labels/E-less-easy","name":"E-less-easy","color":"4296b4","default":false},{"id":621119785,"url":"https://api.github.com/repos/habitat-sh/habitat/labels/L-rust","name":"L-rust","color":"5c6670","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/habitat-sh/habitat/milestones/3","html_url":"https://github.com/habitat-sh/habitat/milestone/3","labels_url":"https://api.github.com/repos/habitat-sh/habitat/milestones/3/labels","id":2179770,"number":3,"title":"Help Wanted","description":null,"creator":{"login":"smurawski","id":4006985,"avatar_url":"https://avatars0.githubusercontent.com/u/4006985?v=4","gravatar_id":"","url":"https://api.github.com/users/smurawski","html_url":"https://github.com/smurawski","followers_url":"https://api.github.com/users/smurawski/followers","following_url":"https://api.github.com/users/smurawski/following{/other_user}","gists_url":"https://api.github.com/users/smurawski/gists{/gist_id}","starred_url":"https://api.github.com/users/smurawski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smurawski/subscriptions","organizations_url":"https://api.github.com/users/smurawski/orgs","repos_url":"https://api.github.com/users/smurawski/repos","events_url":"https://api.github.com/users/smurawski/events{/privacy}","received_events_url":"https://api.github.com/users/smurawski/received_events","type":"User","site_admin":false},"open_issues":74,"closed_issues":36,"state":"open","created_at":"2016-12-06T20:42:42Z","updated_at":"2017-10-01T22:01:12Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2017-08-16T14:00:11Z","updated_at":"2017-10-06T19:06:54Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"<details>\r\n<summary>Version info</summary>\r\nThis is OSX; hab version is `0.29.1/20170810235219`, docker is\r\n```\r\nVersion 17.07.0-ce-rc2-mac22 (18909)\r\nChannel: edge\r\nd9a9cf3b45\r\n```\r\n</details>\r\n\r\n### MWE\r\n\r\nHaving run `build` and `hab pkg export docker srenatus/postgresql`, I'm trying to start `$HAB_ORIGIN/postgresql` via this entry in `docker-compose.yml`:\r\n\r\n```yaml\r\nversion: '3'\r\nservices:\r\n  postgres:\r\n    image: $HAB_ORIGIN/postgresql:latest\r\n    environment:\r\n      - HAB_POSTGRESQL={\"max_connections\":100}\r\n```\r\n\r\nThis is what happens:\r\n\r\n```\r\n$ docker-compose up\r\nCreating habitat_postgres_1 ...\r\nCreating habitat_postgres_1 ... done\r\nAttaching to habitat_postgres_1\r\npostgres_1  | ∵ Missing package for core/hab-launcher\r\npostgres_1  | » Installing core/hab-launcher\r\npostgres_1  | ↓ Downloading core/hab-launcher/4571/20170727193541\r\npostgres_1  | ☛ Verifying core/hab-launcher/4571/20170727193541\r\npostgres_1  | → Using core/bzip2/1.0.6/20170513212938\r\npostgres_1  | → Using core/cacerts/2017.01.18/20170513215104\r\npostgres_1  | → Using core/gcc-libs/5.2.0/20170513212920\r\npostgres_1  | → Using core/glibc/2.22/20170513201042\r\npostgres_1  | → Using core/libarchive/3.2.0/20170514021649\r\npostgres_1  | → Using core/libsodium/1.0.11/20170514010744\r\npostgres_1  | → Using core/linux-headers/4.3/20170513200956\r\npostgres_1  | → Using core/openssl/1.0.2j/20170513215106\r\npostgres_1  | → Using core/xz/5.2.2/20170513214327\r\npostgres_1  | → Using core/zlib/1.2.8/20170513201911\r\npostgres_1  | ✓ Installed core/hab-launcher/4571/20170727193541\r\npostgres_1  | ★ Install of core/hab-launcher/4571/20170727193541 complete with 1 new packages installed.\r\npostgres_1  | hab-sup(MR): Supervisor Member-ID 9495775d21bc428c80b0884462bc84fc\r\npostgres_1  | hab-sup(MR): Starting srenatus/postgresql\r\npostgres_1  | hab-sup(MR): Unable to start srenatus/postgresql, hab-sup(CF)[src/manager/service/config.rs:193:20]: Unable to find valid TOML or JSON in HAB_POSTGRESQL ENVVAR\r\npostgres_1  | hab-sup(MR): Starting gossip-listener on 0.0.0.0:9638\r\npostgres_1  | hab-sup(MR): Starting http-gateway on 0.0.0.0:9631\r\n^CERROR: Aborting.\r\n$\r\n```\r\n\r\nputting this in `'...'`,\r\n```yaml\r\n      - HAB_POSTGRESQL='{\"max_connections\":100}'\r\n```\r\ngives the same:\r\n```\r\npostgres_1  | hab-sup(MR): Unable to start srenatus/postgresql, hab-sup(CF)[src/manager/service/config.rs:193:20]: Unable to find valid TOML or JSON in HAB_POSTGRESQL ENVVAR\r\n```\r\n\r\nonly putting the `100` in `\"...\"` works.\r\n<details>\r\n<summary>successful output</summary>\r\n\r\n```\r\npostgres_1  | ✓ Installed core/hab-launcher/4571/20170727193541\r\npostgres_1  | ★ Install of core/hab-launcher/4571/20170727193541 complete with 1 new packages installed.\r\npostgres_1  | hab-sup(MR): Supervisor Member-ID c95213dc89fc4a519dd81bd578d697b1\r\npostgres_1  | hab-sup(MR): Starting srenatus/postgresql\r\npostgres_1  | hab-sup(MR): Starting gossip-listener on 0.0.0.0:9638\r\npostgres_1  | hab-sup(MR): Starting http-gateway on 0.0.0.0:9631\r\npostgres_1  | postgresql.default(SR): Hooks recompiled\r\npostgres_1  | default(CF): Updated pg_hba.conf 6afba5f3837115d82a0e4e8b7f908be4ded3251358b881794fcd4202bb0bf46b\r\npostgres_1  | default(CF): Updated pg_ident.conf 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8\r\npostgres_1  | default(CF): Updated postgresql.conf bfda2c43805112e221ad4441db201dccf3f363fe4c8e2f1a78894dd3973a8d69\r\npostgres_1  | default(CF): Updated .pgpass 77e2dc1737f58c6a9e2b967fbe9f0f0a6ba553a1e76e066fdcb61876f0d2e278\r\npostgres_1  | default(CF): Updated pwfile 30087c89f3dfc2b2179a2b567a67f094cf1cd8b1c6e3cc1473aef95fe65de533\r\npostgres_1  | default(CF): Updated functions.sh a12c6e2ef38bf613035fa7812ae9e93b4d9933864b3136a5bd65604c3719a4f5\r\npostgres_1  | default(CF): Updated wal-e.toml a0fa826ca24c3e474d6de0822ee81a803a523e1802ccb26b6aac939b6d0eb5c3\r\npostgres_1  | default(CF): Updated recovery.conf 278ffa187fa20e455cf5d5442e46adf9aedd991809d3dd0c01b02ad64bd08ad8\r\npostgres_1  | postgresql.default(SR): Configuration recompiled\r\npostgres_1  | postgresql.default(SR): Initializing\r\npostgres_1  | postgresql.default hook[init]:(HK): Executing init hook\r\npostgres_1  | postgresql.default hook[init]:(HK): Making sure hab user owns var, config and data paths\r\npostgres_1  | postgresql.default hook[init]:(HK):  Database does not exist, creating with 'initdb'\r\npostgres_1  | postgresql.default hook[init]:(HK): The files belonging to this database system will be owned by user \"hab\".\r\npostgres_1  | postgresql.default hook[init]:(HK): This user must also own the server process.\r\npostgres_1  | postgresql.default hook[init]:(HK):\r\npostgres_1  | postgresql.default hook[init]:(HK): The database cluster will be initialized with locale \"C\".\r\npostgres_1  | postgresql.default hook[init]:(HK): The default text search configuration will be set to \"english\".\r\npostgres_1  | postgresql.default hook[init]:(HK):\r\npostgres_1  | postgresql.default hook[init]:(HK): Data page checksums are enabled.\r\npostgres_1  | postgresql.default hook[init]:(HK):\r\npostgres_1  | postgresql.default hook[init]:(HK): fixing permissions on existing directory /hab/svc/postgresql/data ... ok\r\npostgres_1  | postgresql.default hook[init]:(HK): creating subdirectories ... ok\r\npostgres_1  | postgresql.default hook[init]:(HK): selecting default max_connections ... 100\r\npostgres_1  | postgresql.default hook[init]:(HK): selecting default shared_buffers ... 128MB\r\npostgres_1  | postgresql.default hook[init]:(HK): selecting dynamic shared memory implementation ... posix\r\npostgres_1  | postgresql.default hook[init]:(HK): creating configuration files ... ok\r\npostgres_1  | postgresql.default hook[init]:(HK): running bootstrap script ... ok\r\npostgres_1  | postgresql.default hook[init]:(HK): performing post-bootstrap initialization ... ok\r\n```\r\n</details>\r\n\r\n### Running outside of docker-compose\r\n\r\nInside the studio, the **same thing** happens, irregardless of the quoting used -- it only works when the key is a string `\"100\"`:\r\n```\r\n[20][default:/src/postgresql:0]# HAB_POSTGRESQL=\"{\\\"max_connections\\\":100}\" hab svc start srenatus/postgresql\r\nhab-sup(MR): Supervisor Member-ID 2072a2773da048fca8d766c0e0db77a0\r\nhab-sup(MR): Starting srenatus/postgresql\r\nhab-sup(MR): Unable to start srenatus/postgresql, hab-sup(CF)[src/manager/service/config.rs:193:20]: Unable to find valid TOML or JSON in HAB_POSTGRESQL ENVVAR\r\nhab-sup(MR): Starting gossip-listener on 0.0.0.0:9638\r\nhab-sup(MR): Starting http-gateway on 0.0.0.0:9631\r\n^Chab-launch(SV): Hasta la vista, services.\r\n```"},"comment":{"url":"https://api.github.com/repos/habitat-sh/habitat/issues/comments/334843757","html_url":"https://github.com/habitat-sh/habitat/issues/2947#issuecomment-334843757","issue_url":"https://api.github.com/repos/habitat-sh/habitat/issues/2947","id":334843757,"user":{"login":"smacfarlane","id":36851,"avatar_url":"https://avatars0.githubusercontent.com/u/36851?v=4","gravatar_id":"","url":"https://api.github.com/users/smacfarlane","html_url":"https://github.com/smacfarlane","followers_url":"https://api.github.com/users/smacfarlane/followers","following_url":"https://api.github.com/users/smacfarlane/following{/other_user}","gists_url":"https://api.github.com/users/smacfarlane/gists{/gist_id}","starred_url":"https://api.github.com/users/smacfarlane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smacfarlane/subscriptions","organizations_url":"https://api.github.com/users/smacfarlane/orgs","repos_url":"https://api.github.com/users/smacfarlane/repos","events_url":"https://api.github.com/users/smacfarlane/events{/privacy}","received_events_url":"https://api.github.com/users/smacfarlane/received_events","type":"User","site_admin":false},"created_at":"2017-10-06T19:06:54Z","updated_at":"2017-10-06T19:06:54Z","author_association":"CONTRIBUTOR","body":"I dug into this and found that serde_json parses positive integers as u64 https://github.com/serde-rs/json/blob/master/src/de.rs#L203-L207 . The deserializer for the TOML Value type doesn't implement `visit_u64`. https://github.com/alexcrichton/toml-rs/blob/master/src/value.rs#L405  I suspect this is because TOML expects integers to be signed 64 bit values. This results in the error `\"invalid type: integer '1', expected any valid TOML value\"`\r\n\r\nTo test, I cloned toml-rs and implemented a `visit_u64` function that casts the value to an i64 and was able to successfully parse the json string `{\"value\": 1}`.  \r\n\r\nI'm debating submitting this change upstream, or if we should deserialize to json (rather than directly to toml) and handle the conversion ourselves so that we could warn the user there may be data loss for values between max(i64) and max(u64). I'd be happy to put hands on keyboard for either of those, probably with a little guidance for the second, or other options that I'm not thinking of. \r\n\r\nTest code: https://gist.github.com/smacfarlane/22891d478f37df959f544c7bd3a5cd52\r\n"}}
{"actor":{"display_login":"smacfarlane"}}