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

fix: fix index validation for PUT requests #6824

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

debug-ing
Copy link
Contributor

fix issues #6822

@CLAassistant
Copy link

CLAassistant commented Feb 3, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Thanks. Did you double-check that the PUT logic below is still correct if idx == len(arr)?

case http.MethodPut:
    // avoid creation of new slice and a second copy (see
    // https://github.com/golang/go/wiki/SliceTricks#insert)
    arr = append(arr, nil)
    copy(arr[idx+1:], arr[idx:])
    arr[idx] = val
    v[part] = arr

@debug-ing
Copy link
Contributor Author

Yes, the PUT logic works correctly when idx == len(arr). It behaves as expected by appending the new element at the end of the array.

@debug-ing
Copy link
Contributor Author

debug-ing commented Feb 4, 2025

Hi, the code is all good—every test is passing except this one CI run. It hit a network issue where the self-hosted runner couldn't reach GitHub’s endpoints during the artifact upload.

@mholt
Copy link
Member

mholt commented Feb 4, 2025

Yeah, we have some known flaky tests. Thanks!

@mholt mholt merged commit 96c5c55 into caddyserver:master Feb 4, 2025
33 checks passed
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

Successfully merging this pull request may close these issues.

Caddy API PUT array insertion doesn't allow inserting at the end of the array
3 participants