v1.0.11 - #42
Conversation
The axios refactor in dc5211f dropped the USER_AGENT constant but left a reference to it in testApiConnection's headers. That threw a ReferenceError on every health check, which the surrounding catch swallowed into a plain `false` — so the connection test reported the API as unreachable even when it was up. Restore the constant and set it as a default header on the shared axios instance so all three calls (/health, publish, re-initialize) send it and it cannot be dropped piecemeal again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fix(api): restore User-Agent header on API requests
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a CLI-specific User-Agent header to all axios requests via the shared apiClient and removes the now-redundant per-call header in the health check helper. Sequence diagram for apiClient User-Agent header handlingsequenceDiagram
participant CLI
participant apiClient
participant Server
CLI->>apiClient: apiClient.get(baseUrl + /health)
activate apiClient
apiClient->>Server: GET /health
Server-->>apiClient: 200 OK
deactivate apiClient
Note right of apiClient: All requests include header\nUser-Agent: vnext-workflow-cli/<pkg.version>
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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.
Hey - I've found 1 issue, and left some high level feedback:
- Importing
../../package.jsondirectly fromsrc/lib/api.jscan cause issues with some bundlers/runtimes; consider passing the version in via configuration or environment to decouple the library code from the repository layout. - By setting the
User-Agenton the axios instance, all consumers ofapiClientwill now send this CLI-specific header; ifapiClientis shared beyond the CLI context, consider scoping this header to CLI usage only or allowing an easy override.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Importing `../../package.json` directly from `src/lib/api.js` can cause issues with some bundlers/runtimes; consider passing the version in via configuration or environment to decouple the library code from the repository layout.
- By setting the `User-Agent` on the axios instance, all consumers of `apiClient` will now send this CLI-specific header; if `apiClient` is shared beyond the CLI context, consider scoping this header to CLI usage only or allowing an easy override.
## Individual Comments
### Comment 1
<location path="src/lib/api.js" line_range="15" />
<code_context>
rejectUnauthorized: false // Allow self-signed certificates
- })
+ }),
+ headers: { 'User-Agent': USER_AGENT }
});
</code_context>
<issue_to_address>
**issue (bug_risk):** Setting `headers` at the instance level may override axios’s per-method default headers.
Passing a flat `headers` object into `axios.create` can overwrite axios’s per-method defaults (e.g. `Content-Type` on POST/PUT). To avoid dropping these, either set `apiClient.defaults.headers.common['User-Agent'] = USER_AGENT` after creation, or use `headers: { common: { 'User-Agent': USER_AGENT } }` so existing defaults are preserved.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| rejectUnauthorized: false // Allow self-signed certificates | ||
| }) | ||
| }), | ||
| headers: { 'User-Agent': USER_AGENT } |
There was a problem hiding this comment.
issue (bug_risk): Setting headers at the instance level may override axios’s per-method default headers.
Passing a flat headers object into axios.create can overwrite axios’s per-method defaults (e.g. Content-Type on POST/PUT). To avoid dropping these, either set apiClient.defaults.headers.common['User-Agent'] = USER_AGENT after creation, or use headers: { common: { 'User-Agent': USER_AGENT } } so existing defaults are preserved.
Summary by Sourcery
Enhancements: