fix(BL): Saved Queries Uploads Not Using Ingest File Checks BED-7040#2786
fix(BL): Saved Queries Uploads Not Using Ingest File Checks BED-7040#2786ALCooper12 wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds UTF-8 BOM normalization to saved-query imports: the stream ZIP reader normalizes ZIP entry contents, the JSON import path normalizes request bodies, and tests validate both BOM scenarios. ChangesUTF-8 BOM Normalization for Saved Query Imports
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/api/src/api/v2/saved_queries.go`:
- Around line 413-415: The NormalizeToUTF8 failure is currently propagated as a
generic error and becomes a 500; change ImportSavedQueries to treat
NormalizeToUTF8 normalization errors as a client bad request (400).
Specifically, when calling bomenc.NormalizeToUTF8 (and where you return
fmt.Errorf("failed to normalize json file: %w", err)), convert or wrap that
error into the API's BadRequest/user input error type and add a case in the
ImportSavedQueries error-handling switch to map that normalization error to a
400 response (referencing the NormalizeToUTF8 call and the "failed to normalize
json file" message to locate the code).
In `@cmd/api/src/services/upload/streamdecoder.go`:
- Around line 379-385: The ZIP entry opened via zf.Open() is not closed if
bomenc.NormalizeToUTF8(f) returns an error because defer f.Close() is registered
after the normalization; update the logic in streamdecoder.go around zf.Open(),
bomenc.NormalizeToUTF8, and the defer to ensure f.Close() is invoked on every
path (e.g., call defer f.Close() immediately after successful zf.Open() or
explicitly close f before returning on normalization error) so that the ZIP
entry is never leaked.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 629c529f-0359-4598-9e72-3ff54af452f4
📒 Files selected for processing (3)
cmd/api/src/api/v2/saved_queries.gocmd/api/src/api/v2/saved_queries_test.gocmd/api/src/services/upload/streamdecoder.go
Description
streamdecoder.goandsaved_queries.goin order to utilize BOM normalization for the ImportSavedQueries endpointMotivation and Context
This PR addresses:
Why is this change required? What problem does it solve?
How Has This Been Tested?
Screenshots (optional):
Types of changes
Checklist:
Summary by CodeRabbit
Bug Fixes
Tests