Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughA new CLI flag Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 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 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.
Pull request overview
This PR adds a CLI-level mechanism for supplying user-defined HTTP headers that are automatically included on all OpenFGA API requests, addressing #669 for deployments that require non-standard auth headers.
Changes:
- Introduces a new
--custom-headerspersistent flag and wires it intoClientConfig. - Parses provided header strings into a
map[string]stringand passes them via the SDKDefaultHeadersconfiguration. - Extends the serialized client config model to include
custom_headers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
internal/fga/fga.go |
Adds CustomHeaders to config and applies parsed headers through the SDK client configuration. |
internal/cmdutils/get-client-config.go |
Reads the new custom-headers flag into fga.ClientConfig. |
cmd/root.go |
Registers the new persistent --custom-headers flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cmd/root.go (1)
71-71: Clarify--custom-headersvalue format in help text.Consider documenting the expected format (for example,
Header-Name:Header Value) directly in the flag description to reduce invalid input.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/root.go` at line 71, Update the flag description for rootCmd.PersistentFlags().StringArray("custom-headers", ...) to clarify the expected input format and reduce invalid values by documenting an example like "Header-Name: Header Value" and specifying that the colon separates name and value and the flag can be repeated for multiple headers; modify only the description string passed to StringArray for the "custom-headers" flag to include this format guidance and an example.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/fga/fga.go`:
- Around line 104-113: The getCustomHeaders method currently adds headers even
when the parsed header name is empty (e.g., ":value"); update
ClientConfig.getCustomHeaders to ignore entries with empty header names by
trimming parts[0] and checking head != "" before assigning headers[head] =
value, keeping the rest of the parsing logic the same so only valid non-empty
header keys are included.
---
Nitpick comments:
In `@cmd/root.go`:
- Line 71: Update the flag description for
rootCmd.PersistentFlags().StringArray("custom-headers", ...) to clarify the
expected input format and reduce invalid values by documenting an example like
"Header-Name: Header Value" and specifying that the colon separates name and
value and the flag can be repeated for multiple headers; modify only the
description string passed to StringArray for the "custom-headers" flag to
include this format guidance and an example.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 605667f4-98bb-4e92-9330-aac2d46d26b7
📒 Files selected for processing (3)
cmd/root.gointernal/cmdutils/get-client-config.gointernal/fga/fga.go
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
One more thing - can we add some tests for these, just to make sure all is good? And please make sure to run |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Just a general comment, i happened to look at this and noticed that for env variables we have a bug in: If the custom headers is passed as an env variable it will stringify the the string array. It will probably work with one entry. not sure how likely env vars are in your use case but i assume it would be for some auth headers and maybe not multiple. this is not a problem with your PR but its a bug that came to light because of it. @rhamzeh - ill create a separate issue for this. UPDATE: and i just noticed that co-pilot already flagged this. |
|
Thanks @alexanderzobnin - we'll fix the lint issue and merge :) @emilic please do! |
|
@alexanderzobnin can I ask you to either:
These are the changes needed:
|
There was a problem hiding this comment.
This is what @rhamzeh asked to do (this was a part of go toolchain bump).
There was a problem hiding this comment.
@rhamzeh was the addition of this file the intent? I wasn't sure if we were actually using the tool in the project.
Description
What problem is being solved?
Solves #669
How is it being solved?
Provide new
--custom-headersflag which allows to pass custom user-defined headers which are then included to every request to API.What changes are made to solve it?
Implemented new
--custom-headersoption by utilizing existingDefaultHeadersclient config field.References
Review Checklist
mainSummary by CodeRabbit
--custom-headersCLI flag. This repeatable flag accepts header values inname:valueformat, enabling users to include custom headers in requests.