api: container, exec resize: improve errors for invalid width/height#48679
Merged
thaJeztah merged 6 commits intomoby:masterfrom Oct 17, 2024
Merged
api: container, exec resize: improve errors for invalid width/height#48679thaJeztah merged 6 commits intomoby:masterfrom
thaJeztah merged 6 commits intomoby:masterfrom
Conversation
thaJeztah
commented
Oct 16, 2024
863c8e0 to
71b7357
Compare
vvoland
approved these changes
Oct 17, 2024
laurazard
approved these changes
Oct 17, 2024
thaJeztah
commented
Oct 17, 2024
| return 0, errors.Unwrap(err) | ||
| } | ||
| if isNeg { | ||
| return 0, strconv.ErrRange |
Member
Author
There was a problem hiding this comment.
FWIW; I was on the fence whether to make this function return an errdefs.Invalid on its own, but as we will likely always wrap the error to decorate it with some message ("invalid XYZ"), it would be a bit double.
Doing decorating as part of this function would've worked, using the field name that's passed, but in the current uses, those fields would be w or h, which would be a bit too obscure for an error message, and I don't think we want to change the API to use ?width=xxx,height=xxx just for that purpose 😂
We can still consider doing so at some point though (to prevent consumers forgetting to add a errdefs type.
71b7357 to
dc57c80
Compare
Member
Author
|
Rebased, and addressed the comments 👍 |
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
…height Containerd accepts uints for these, so make the backend signature align with that, so that we don't have to cast values. Also pass the context along. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
…th, height Containerd accepts uints for these, so make the backend signature align with that, so that we don't have to cast values. Also pass the context along. Signed-off-by: Sebastiaan van Stijn <[email protected]>
…ight Mostly theoretical, but let's be correct here. It's worth noting that the API (backend) accepts uint32, but container.ResizeOptions uses uint (uint64). We could decide to add checks for this on the client side, or to change the type (but that would be a breaking change). Signed-off-by: Sebastiaan van Stijn <[email protected]>
dc57c80 to
abed0e1
Compare
Member
Author
|
Are you OK, Docker Hub? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
api/server/httputils: add Uint32Value utility
api: container resize: improve errors for invalid width/height
api: backend.ContainerResize: pass context and use uint32 for width, height
Containerd accepts uints for these, so make the backend signature align
with that, so that we don't have to cast values. Also pass the context
along.
api: exec resize: improve errors for invalid width/height
api: backend.ContainerExecResize: pass context and use uint32 for width, height
Containerd accepts uints for these, so make the backend signature align
with that, so that we don't have to cast values. Also pass the context
along.
client: ContainerResize, ContainerExecResize: don't overflow width/height
Mostly theoretical, but let's be correct here. It's worth noting that the API
(backend) accepts uint32, but container.ResizeOptions uses uint (uint64). We
could decide to add checks for this on the client side, or to change the
type (but that would be a breaking change).
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)