fix: use providerCfgInFile instead of existingCfg when preserving failed provider config - #4258
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughReconciliation now always builds authoritative provider entries from config.json. processAuthoritativeProvider no longer returns errors; validation failures are logged as warnings and processing (normalization, key ID generation, hash computation, and merging with stored provider fields) continues. ChangesProvider Configuration Reconciliation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
providerCfgInFile instead of existingCfg when preserving failed provider config
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@transports/bifrost-http/lib/config.go`:
- Around line 1162-1164: When processAuthoritativeProvider(providerName,
providerCfgInFile, existingCfg, exists, authoritativeProviders) returns an
error, don't stash the raw providerCfgInFile into authoritativeProviders as-is;
instead merge the identifying fields and metadata from existingCfg (key IDs,
each key's ID, Status, Description, and any provider-level metadata) into the
fallback before assigning authoritativeProviders[provider] = providerCfgInFile
so that keepKeys (built later in syncAuthoritativeProvidersInStore) retains
existing key IDs and provider/key Status/Description; implement this merge right
inside the error branch where logger.Warn is called, referencing
processAuthoritativeProvider, providerCfgInFile, existingCfg,
authoritativeProviders, and syncAuthoritativeProvidersInStore to ensure
preserved IDs and metadata are copied into the fallback entry.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 1e242039-fd57-4e8a-89b0-0bd7b48388fe
📒 Files selected for processing (1)
transports/bifrost-http/lib/config.go
Confidence Score: 5/5Safe to merge. The change is narrow, the write-through intent is consistent across all code paths, and key/status/description merging with existing DB entries is preserved correctly. The refactor is minimal and well-scoped: removing the error-return from No files require special attention. Important Files Changed
Reviews (7): Last reviewed commit: "feat: overwrite even if not valid fields" | Re-trigger Greptile |
972dba0 to
d621fa7
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@transports/bifrost-http/lib/config.go`:
- Around line 1162-1163: The call to processAuthoritativeProvider currently
writes provider entries without validating CustomProviderConfig or key aliases,
allowing malformed input into config.json; restore provider-level validation by
invoking the same validation logic that was removed (validate
CustomProviderConfig structure and each key alias) before persisting and add a
failure path that logs/returns a warning/error for that provider so it is not
written-through on invalid input; update processAuthoritativeProvider (and its
callers where providerName and providerCfgInFile are passed) to perform these
checks and produce clear validation warnings (or skip/purge the provider entry)
while preserving write-through behavior for valid providers.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 8dda7e40-b4e2-4241-a913-17b0cafb5aee
📒 Files selected for processing (1)
transports/bifrost-http/lib/config.go
108fc07 to
e90f7d4
Compare
223f010 to
39adfe1
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@transports/bifrost-http/lib/config.go`:
- Around line 2764-2766: The UUID for new file-defined virtual keys is being
assigned after virtualKeysToAdd has already been appended to
config.GovernanceConfig.VirtualKeys in mergeGovernanceConfig, so the live
in-memory config still contains entries with ID == "". Move the assignment of
virtualKey.ID = uuid.NewString() into the code path that constructs/populates
virtualKeysToAdd (i.e., when you create each virtualKey before you append it to
the slice in mergeGovernanceConfig), ensuring every virtual key has an ID prior
to append; retain the current check (if virtualKey.ID == "" { virtualKey.ID =
uuid.NewString() }) only as a defensive assert in the later function to cover
any unexpected cases.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 21fe24ae-1dbf-4a23-9fef-ac3757c5bfca
📒 Files selected for processing (1)
transports/bifrost-http/lib/config.go
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🤖 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 `@transports/bifrost-http/lib/config.go`:
- Around line 2764-2766: The UUID for new file-defined virtual keys is being
assigned after virtualKeysToAdd has already been appended to
config.GovernanceConfig.VirtualKeys in mergeGovernanceConfig, so the live
in-memory config still contains entries with ID == "". Move the assignment of
virtualKey.ID = uuid.NewString() into the code path that constructs/populates
virtualKeysToAdd (i.e., when you create each virtualKey before you append it to
the slice in mergeGovernanceConfig), ensuring every virtual key has an ID prior
to append; retain the current check (if virtualKey.ID == "" { virtualKey.ID =
uuid.NewString() }) only as a defensive assert in the later function to cover
any unexpected cases.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 21fe24ae-1dbf-4a23-9fef-ac3757c5bfca
📒 Files selected for processing (1)
transports/bifrost-http/lib/config.go
🛑 Comments failed to post (1)
transports/bifrost-http/lib/config.go (1)
2764-2766:
⚠️ Potential issue | 🟠 Major | ⚡ Quick winAssign the virtual-key ID before the merge result is copied into in-memory config.
mergeGovernanceConfigappendsvirtualKeysToAddintoconfig.GovernanceConfig.VirtualKeysbefore this function runs, so generating the UUID here only mutates the localvirtualKeysToAddcopy. The live in-memory governance config still carriesID == ""for newly added file-defined virtual keys until a later restart/name-match reconcile fixes it. Generate the ID when buildingvirtualKeysToAdd(before the append at Line 2334), and keep this branch as a defensive assert at most.🤖 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 `@transports/bifrost-http/lib/config.go` around lines 2764 - 2766, The UUID for new file-defined virtual keys is being assigned after virtualKeysToAdd has already been appended to config.GovernanceConfig.VirtualKeys in mergeGovernanceConfig, so the live in-memory config still contains entries with ID == "". Move the assignment of virtualKey.ID = uuid.NewString() into the code path that constructs/populates virtualKeysToAdd (i.e., when you create each virtualKey before you append it to the slice in mergeGovernanceConfig), ensuring every virtual key has an ID prior to append; retain the current check (if virtualKey.ID == "" { virtualKey.ID = uuid.NewString() }) only as a defensive assert in the later function to cover any unexpected cases.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Merge activity
|
e90f7d4 to
fd682f5
Compare
fd682f5 to
ffef137
Compare
… failed provider config (#4258) ## Summary When processing an authoritative provider fails, the provider's file-based config should still be written to the store rather than silently falling back to the previously persisted config. The old behavior preserved the existing store entry on error, which could mask bad config and prevent updates from taking effect. ## Changes - On a failed `processAuthoritativeProvider` call, the provider entry in `authoritativeProviders` is now set to `providerCfgInFile` (the config as read from the file) instead of `existingCfg` (the previously persisted config). - This ensures that a malformed or invalid provider config in the file is surfaced and written through, rather than silently falling back to stale data that could hide the problem. ## Type of change - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [x] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Deploy a configuration with a provider entry that triggers a processing error and verify that the provider's config in the store reflects the file-based config rather than the previously persisted value. ```sh go test ./... ``` ## Screenshots/Recordings N/A ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations No direct security implications. Ensuring the file-based config is authoritative prevents stale or unintended provider configs from persisting silently in the store. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Authoritative provider entries from config files are now always processed during reconciliation, streamlining validation and merge behavior. * Validation failures are logged as warnings but no longer block processing; missing key IDs are generated and provider/key data are normalized. * **Bug Fix** * When a provider already exists, file-specified keys are merged with stored keys while preserving the provider's existing status and description, preventing inadvertent pruning. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
… failed provider config (maximhq#4258) ## Summary When processing an authoritative provider fails, the provider's file-based config should still be written to the store rather than silently falling back to the previously persisted config. The old behavior preserved the existing store entry on error, which could mask bad config and prevent updates from taking effect. ## Changes - On a failed `processAuthoritativeProvider` call, the provider entry in `authoritativeProviders` is now set to `providerCfgInFile` (the config as read from the file) instead of `existingCfg` (the previously persisted config). - This ensures that a malformed or invalid provider config in the file is surfaced and written through, rather than silently falling back to stale data that could hide the problem. ## Type of change - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [x] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Deploy a configuration with a provider entry that triggers a processing error and verify that the provider's config in the store reflects the file-based config rather than the previously persisted value. ```sh go test ./... ``` ## Screenshots/Recordings N/A ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations No direct security implications. Ensuring the file-based config is authoritative prevents stale or unintended provider configs from persisting silently in the store. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Authoritative provider entries from config files are now always processed during reconciliation, streamlining validation and merge behavior. * Validation failures are logged as warnings but no longer block processing; missing key IDs are generated and provider/key data are normalized. * **Bug Fix** * When a provider already exists, file-specified keys are merged with stored keys while preserving the provider's existing status and description, preventing inadvertent pruning. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
… failed provider config (maximhq#4258) ## Summary When processing an authoritative provider fails, the provider's file-based config should still be written to the store rather than silently falling back to the previously persisted config. The old behavior preserved the existing store entry on error, which could mask bad config and prevent updates from taking effect. ## Changes - On a failed `processAuthoritativeProvider` call, the provider entry in `authoritativeProviders` is now set to `providerCfgInFile` (the config as read from the file) instead of `existingCfg` (the previously persisted config). - This ensures that a malformed or invalid provider config in the file is surfaced and written through, rather than silently falling back to stale data that could hide the problem. ## Type of change - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [x] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Deploy a configuration with a provider entry that triggers a processing error and verify that the provider's config in the store reflects the file-based config rather than the previously persisted value. ```sh go test ./... ``` ## Screenshots/Recordings N/A ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations No direct security implications. Ensuring the file-based config is authoritative prevents stale or unintended provider configs from persisting silently in the store. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Authoritative provider entries from config files are now always processed during reconciliation, streamlining validation and merge behavior. * Validation failures are logged as warnings but no longer block processing; missing key IDs are generated and provider/key data are normalized. * **Bug Fix** * When a provider already exists, file-specified keys are merged with stored keys while preserving the provider's existing status and description, preventing inadvertent pruning. <!-- end of auto-generated comment: release notes by coderabbit.ai -->

Summary
When processing an authoritative provider fails, the provider's file-based config should still be written to the store rather than silently falling back to the previously persisted config. The old behavior preserved the existing store entry on error, which could mask bad config and prevent updates from taking effect.
Changes
processAuthoritativeProvidercall, the provider entry inauthoritativeProvidersis now set toproviderCfgInFile(the config as read from the file) instead ofexistingCfg(the previously persisted config).Type of change
Affected areas
How to test
Deploy a configuration with a provider entry that triggers a processing error and verify that the provider's config in the store reflects the file-based config rather than the previously persisted value.
go test ./...Screenshots/Recordings
N/A
Breaking changes
Related issues
N/A
Security considerations
No direct security implications. Ensuring the file-based config is authoritative prevents stale or unintended provider configs from persisting silently in the store.
Checklist
docs/contributing/README.mdand followed the guidelinesSummary by CodeRabbit
Refactor
Bug Fix