Skip to content

fix: fix index validation for PUT requests - #6824

Merged
mholt merged 1 commit into
caddyserver:masterfrom
debug-ing:fix/caddy-api-put-6822
Feb 4, 2025
Merged

mholt merged 1 commit into
caddyserver:masterfrom
debug-ing:fix/caddy-api-put-6822

Conversation

@debug-ing

Copy link
Copy Markdown
Contributor

fix issues #6822

@CLAassistant

CLAassistant commented Feb 3, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@mholt mholt left a comment •

Copy link
Copy Markdown
Member

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
Copy Markdown
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

debug-ing commented Feb 4, 2025 •

Copy link
Copy Markdown
Contributor Author

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

mholt commented Feb 4, 2025

Copy link
Copy Markdown
Member

Yeah, we have some known flaky tests. Thanks!

@mholt
mholt merged commit 96c5c55 into caddyserver:master Feb 4, 2025
mohammed90 pushed a commit to cedricziel/caddy that referenced this pull request Aug 29, 2025
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