Skip to content

docs: api: document w (width) and h (height) query params as required#48663

Merged
vvoland merged 2 commits intomoby:masterfrom
thaJeztah:api_resize_required
Oct 15, 2024
Merged

docs: api: document w (width) and h (height) query params as required#48663
vvoland merged 2 commits intomoby:masterfrom
thaJeztah:api_resize_required

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

Query parameters default to being optional in swagger, but for these
endpoints, they were required. Omitting these parameters (or passing an
empty value) produces a 400 (bad request);

docker run -d --name foo nginx:alpine

curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize'
{"message":"strconv.Atoi: parsing \"\": invalid syntax"}

curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w='
{"message":"strconv.Atoi: parsing \"\": invalid syntax"}

curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=&h='
{"message":"strconv.Atoi: parsing \"\": invalid syntax"}

curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h='
{"message":"strconv.Atoi: parsing \"\": invalid syntax"}

curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h=100'

This patch updates the swagger to reflect that these parameters are required.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Query parameters default to being _optional_ in swagger, but for these
endpoints, they were required. Omitting these parameters (or passing an
empty value) produces a 400 (bad request);

    docker run -d --name foo nginx:alpine

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize'
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=&h='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h=100'

This patch amends the swagger to reflect that these parameters are required.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Query parameters default to being _optional_ in swagger, but for these
endpoints, they were required. Omitting these parameters (or passing an
empty value) produces a 400 (bad request);

    docker run -d --name foo nginx:alpine

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize'
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=&h='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h=100'

This patch updates the swagger to reflect that these parameters are required.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Copy link
Copy Markdown
Contributor

@austinvazquez austinvazquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find 👏🏼

@vvoland vvoland merged commit 97b1233 into moby:master Oct 15, 2024
@thaJeztah thaJeztah deleted the api_resize_required branch October 15, 2024 09:27
@thaJeztah
Copy link
Copy Markdown
Member Author

Nice find 👏🏼

Thanks! I was a bit on the fence initially, because in most cases, query-parameters are optional. We also (currently at least) accept ?w=0&h=0, which could be considered "somewhat equivalent" to omitting the parameters.

But as the API already rejected these (whether by design or not), and thus nobody would already be able to depend on this, I decided to officiate it. I have some patches in my local fork to improve some of these errors (first step was to improve test-coverage, but I need to look at making it work for Windows, which apparently has different behavior between builtin and containerd as runtime; #48665)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants