fix(lcm): Fixing invalid content type with version - #2091
fix(lcm): Fixing invalid content type with version#2091hung-nguyen-hoang wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 41 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe response parser now accepts versioned UTF-8 JSON content types. The project version was updated from ChangesJSON response handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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 `@lib/gooddata/rest/connection.rb`:
- Around line 650-652: Update content_type_with_version so versioned
application/json content types are accepted without requiring charset=UTF-8;
retain the existing non-empty, JSON, and version checks so process_response
recognizes values such as application/json; version=1.
- Around line 650-652: Update content_type_with_version to return false when
content_type is nil before calling empty?, while preserving the existing
validation for non-nil content types.
🪄 Autofix
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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e470b087-e4c8-4c37-9375-d9a5517ab8f1
📒 Files selected for processing (2)
VERSIONlib/gooddata/rest/connection.rb
| def content_type_with_version(content_type) | ||
| !content_type.empty? && content_type.include?('application/json') && content_type.include?('charset=UTF-8') && content_type.include?('version=') | ||
| end |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Recognize versioned JSON without requiring a charset parameter.
The supplied fixture spec/integration/vcr_cassettes/GoodData_AdsOutputStage/should_be_able_to_create_output_stage.yml, Line 11, contains application/json; version=1. The helper returns false because this value lacks charset=UTF-8. process_response then raises Unsupported response content type at Line 645. Make the charset parameter optional when the content type is versioned JSON.
Proposed fix
def content_type_with_version(content_type)
- !content_type.empty? && content_type.include?('application/json') && content_type.include?('charset=UTF-8') && content_type.include?('version=')
+ !content_type.empty? && content_type.include?('application/json') && content_type.include?('version=')
end📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def content_type_with_version(content_type) | |
| !content_type.empty? && content_type.include?('application/json') && content_type.include?('charset=UTF-8') && content_type.include?('version=') | |
| end | |
| def content_type_with_version(content_type) | |
| !content_type.empty? && content_type.include?('application/json') && content_type.include?('version=') | |
| end |
🤖 Prompt for 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.
In `@lib/gooddata/rest/connection.rb` around lines 650 - 652, Update
content_type_with_version so versioned application/json content types are
accepted without requiring charset=UTF-8; retain the existing non-empty, JSON,
and version checks so process_response recognizes values such as
application/json; version=1.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Prevent content_type_with_version from crashing on nil.
process_response already handles content_type.nil? at Line 640. The new call at Line 622 runs first. When the response has no Content-Type, Line 651 calls empty? on nil and raises NoMethodError. Return false before calling empty?.
Proposed fix
def content_type_with_version(content_type)
- !content_type.empty? && content_type.include?('application/json') && content_type.include?('charset=UTF-8') && content_type.include?('version=')
+ content_type && !content_type.empty? && content_type.include?('application/json') && content_type.include?('charset=UTF-8') && content_type.include?('version=')
end📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def content_type_with_version(content_type) | |
| !content_type.empty? && content_type.include?('application/json') && content_type.include?('charset=UTF-8') && content_type.include?('version=') | |
| end | |
| def content_type_with_version(content_type) | |
| content_type && !content_type.empty? && content_type.include?('application/json') && content_type.include?('charset=UTF-8') && content_type.include?('version=') | |
| end |
🤖 Prompt for 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.
In `@lib/gooddata/rest/connection.rb` around lines 650 - 652, Update
content_type_with_version to return false when content_type is nil before
calling empty?, while preserving the existing validation for non-nil content
types.
5ec681a to
71cc4a2
Compare
Jira: GRIF-987
Summary by CodeRabbit
Bug Fixes
Chores