fix: force UTF-8 encoding on HTTP response body + CLI docs#131
fix: force UTF-8 encoding on HTTP response body + CLI docs#131
Conversation
Also adds prominent CLI documentation to README with examples of using pre-trained remote models. Bump version to 2.3.2
Greptile SummaryThis PR adds a targeted encoding fix and improves CLI documentation. The changes build on PR #130's global encoding defaults by adding an explicit The README additions provide clear CLI examples with pre-trained models ( Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CLI
participant GitHub
User->>CLI: classify with -r flag
CLI->>CLI: fetch_github_file(registry, file_path)
CLI->>GitHub: GET /registry/main/file_path
alt Success
GitHub-->>CLI: HTTP 200 + body (ASCII-8BIT)
CLI->>CLI: force_encoding(UTF-8)
CLI-->>User: classification result
else Main branch fails
GitHub-->>CLI: HTTP 404/error
CLI->>GitHub: GET /registry/master/file_path
alt Master success
GitHub-->>CLI: HTTP 200 + body (ASCII-8BIT)
CLI->>CLI: force_encoding(UTF-8)
CLI-->>User: classification result
else Master fails
GitHub-->>CLI: HTTP 404/error
CLI-->>User: error message
end
end
|
There was a problem hiding this comment.
Additional Comments (1)
-
lib/classifier/cli.rb, line 864-869 (link)style: nested conditionals checking same condition, refactor with early return
Or inline:
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
3 files reviewed, 1 comment
Summary
Problem
When downloading remote models in environments with C/POSIX locales (like Homebrew's test sandbox), the HTTP response body defaults to ASCII-8BIT encoding, causing:
Solution
Call
force_encoding(Encoding::UTF_8)on the response body infetch_github_file.README Updates
Added a new "Command Line" section after Installation showing:
-rflag