Repository navigation
fix(api): accept an empty body on the AI analysis trigger - #523
Merged
Merged
Conversation
The trigger body is documented as optional and the first example in docs/integrations/ai-analysis.md sends none, but the handler answered 400 "invalid JSON body" because decodeJSON returns io.EOF for an empty body. Treat io.EOF as "no fields", as the other optional-body handlers do. Malformed JSON is still rejected. Fixes openartifact#508
Merged
Merged
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.
Fixes #508.
POST /api/v1/repositories/{name}/ai-analysis/{artifactID}/triggeranswered400 invalid JSON bodyfor a request without a body, although every body field is optional and the first example indocs/integrations/ai-analysis.mdsends none.decodeJSONreturnsio.EOFfor an empty body and the handler treated any error as bad JSON.The handler now treats
io.EOFas "no fields", the same way the other optional-body handlers do (admin_gpg.go,admin_signing_key.go,docker_gc.go,bundles.go). Malformed JSON is still rejected with 400.Tests
Three cases added to
TestAITriggerWithoutManifestText:{): 400The first two fail on
mainwith 400 and pass with the change.go test -short -race ./internal/api/,go vet(with and without-tags noai) andgolangci-lintv2.15.0 on./internal/api/...pass locally; I did not run the fullmake test/make check.