Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0.1 causes error: "invalid character '/' looking for beginning of value" #139

Closed
pdcastro opened this issue Jan 14, 2022 · 1 comment
Closed

Comments

@pdcastro
Copy link

docker-modem v3.0.1 / PR #133 (then modified by PR #134 / v3.0.2) introduced a bug that manifests as the following image build error message when the build options include a volumes array -

{
  volumes: [ '/var/lib/docker/tmp:/var/lib/docker/tmp:rw' ],
  ...
}
(HTTP code 500) server error - invalid character '/' looking for beginning of value

I had already added a comment to the PR itself (#133 (comment)). Now creating this issue so that the comment does not get forgotten too easily.

The query string produced by the buildQuerystring function (see #133) is:

Before PR #133:

't=balena-secrets%3Alatest&volumes=%5B%22%2Fvar%2Flib%2Fdocker%2Ftmp%3A%2Fvar%2Flib%2Fdocker%2Ftmp%3Arw%22%5D&forcerm=true'

→ The volumes array was stringified as '["/var/lib/docker/tmp:/var/lib/docker/tmp:rw"]' prior to conversion to a query string, and the image build would succeed.

After PR #133:

't=balena-secrets%3Alatest&volumes=%2Fvar%2Flib%2Fdocker%2Ftmp%3A%2Fvar%2Flib%2Fdocker%2Ftmp%3Arw&forcerm=true'

→ The volumes array is not stringified, and this causes Docker (balenaEngine) to produce the HTTP 500 server error quoted above.

This issue was originally reported by a balena CLI end user in balena-io/balena-cli/issues/2440 . The workaround is to downgrade and pin docker-modem to v3.0.0.

cc: @robertgzr

dfunckt added a commit to balena-io-modules/docker-modem that referenced this issue May 27, 2022
Most Docker API parameters take JSON values but some array parameters must be passed as multiple querystring parameters. Two known such parameters are `t` and `extrahosts` for the `/build` endpoint. There may be others.

This changes Modem to behave in a similar way: encode values to JSON by default, except the known special cases.

This properly fixes apocas/dockerode#605 and apocas#139 and effectively reverts apocas#133 and apocas#134.
@dfunckt
Copy link
Contributor

dfunckt commented Jun 15, 2022

Fixed by #144.

@apocas apocas closed this as completed Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants