fix: avoid double-wrapping already-wrapped errors in QueryResources#44
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughReturn the original Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Fixes an error-handling bug in the query service’s QueryResources endpoint where errors produced by payloadToCriteria were being wrapped twice, resulting in empty error messages and incorrect 500 responses for payload/criteria parsing failures.
Changes:
- Return
errCriteriafrompayloadToCriteriadirectly inQueryResourcesinstead of callingwrapErroragain.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
payloadToCriteria already calls wrapError internally and returns a Goa
error type. Calling wrapError again hit the default case and invoked
.Error() on the Goa type, which returns "" by design, producing a 500
response with {"message": ""}.
Also fixes test that was asserting the wrong error type (InternalServerError)
for an invalid page token — it should be BadRequestError.
🤖 Generated with [Claude Code](https://claude.ai/code)
Signed-off-by: Andres Tobon <andrest2455@gmail.com>
996ce22 to
ee42a19
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmd/service/service.go (1)
1-174:⚠️ Potential issue | 🟠 MajorLinting verification failed. Address the following issues before merge:
The repository has 4 linting issues preventing merge:
pkg/httpclient/client.go:105:23: Error return value ofresp.Body.Close()is not checked (errcheck)cmd/service/service_test.go:598:8: Typequerysvc.Serviceshould be omitted from declaration (staticcheck)internal/service/organization_search_test.go:763:9: TypeOrganizationSearchershould be omitted from declaration (staticcheck)internal/service/organization_search_test.go:770:15: TypeOrganizationSearchershould be omitted from declaration (staticcheck)Note: The file under review (
cmd/service/service.go) passes linting; issues are in other files within the PR.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/service/service.go` around lines 1 - 174, Handle the four lint issues: (1) In the code that calls resp.Body.Close(), capture and check its returned error (or defer a closure that checks and logs/returns the error) instead of ignoring it so errcheck is satisfied; (2) In cmd/service/service_test.go remove the explicit type annotation "querysvc.Service" from the variable declaration (use := or var x = ...) so staticcheck no longer complains; (3) In internal/service/organization_search_test.go at the two flagged declarations remove the explicit "OrganizationSearcher" type from those variable declarations (use short declaration or omit the type) so staticcheck is satisfied. Ensure you update only the declarations/callback that match the symbols resp.Body.Close(), querysvc.Service, and OrganizationSearcher.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@cmd/service/service.go`:
- Around line 1-174: Handle the four lint issues: (1) In the code that calls
resp.Body.Close(), capture and check its returned error (or defer a closure that
checks and logs/returns the error) instead of ignoring it so errcheck is
satisfied; (2) In cmd/service/service_test.go remove the explicit type
annotation "querysvc.Service" from the variable declaration (use := or var x =
...) so staticcheck no longer complains; (3) In
internal/service/organization_search_test.go at the two flagged declarations
remove the explicit "OrganizationSearcher" type from those variable declarations
(use short declaration or omit the type) so staticcheck is satisfied. Ensure you
update only the declarations/callback that match the symbols resp.Body.Close(),
querysvc.Service, and OrganizationSearcher.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0847b5a1-0fde-4545-be0e-2b90be5f7f7c
📒 Files selected for processing (1)
cmd/service/service.go
Summary
payloadToCriteriaalready callswrapErrorinternally and returns a Goa error typewrapErroragain on the returned error hit thedefaultcase and invoked.Error()on the Goa type, which returns""by design{"message": ""}for any payload validation error inQueryResources🤖 Generated with Claude Code