feat: inject original query into apitester snapshots#5150
feat: inject original query into apitester snapshots#5150another-rex wants to merge 4 commits intomasterfrom
Conversation
Modifies `normalizeJSONBody` in `tools/apitester/main_test.go` to accept the request body and include the `query` object directly alongside the results in the snapshot output. For single queries, the query is added as a top-level field. For batch queries, each individual query is injected into its corresponding entry in the `results` array. This makes it easier to trace test failures and review data quality by directly mapping responses back to the original request payload. Updated snapshot files to reflect these structural changes. Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Modifies `normalizeJSONBody` in `tools/apitester/main_test.go` to accept the request body and include the `query` object directly alongside the results in the snapshot output. For single queries, the query is added as a top-level field. For batch queries, each individual query is injected into its corresponding entry in the `results` array. This makes it easier to trace test failures and review data quality by directly mapping responses back to the original request payload. Updated snapshot files to reflect these structural changes. This also addresses formatting (gofmt) and staticcheck (`QF1003`) issues found in the initial CI run. Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
|
@jules For clarity, the responses with no vulns should still have the field "vulns: []" to clearly show there are no vulns for that query. |
I've updated |
Addresses PR feedback by injecting an explicit `"vulns": []` field in the API snapshot output for queries that return no vulnerabilities, improving clarity in the snapshots. Run `go mod tidy` as well. Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
Addresses PR feedback to consistently order the `query` object before the `vulns` array in the apitester snapshots for better readability. Re-generated snapshots against `api.test.osv.dev` accordingly. Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
Modifies the APITester to attach the original request query payload directly into the response JSON output before creating snapshots. This is particularly useful for debugging and tracing batch queries, allowing users to map the output to its input in a 1-to-1 manner.
/v1/queryresponses now include a top-level"query"field reflecting the original payload./v1/querybatchresponses map each item inqueriesinto its corresponding object within theresultsarray under"query".github.com/tidwall/sjsonto modify the JSON bodies efficiently.**Note: ** This does result in the snapshots not being exactly 1:1 with what our API actually returns. But since this script will likely break if it isn't in the format we expect, I think that's probably fine tradeoff.
PR created automatically by Jules for task 730514506246798316 started by @another-rex