Skip to content

fix(ui): prevent silent overwrite of existing API key connections on … - #6499

Merged
diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.46from
dilneiss:fix/api-key-modal-unique-default-name
Jul 7, 2026
Merged

diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.46from
dilneiss:fix/api-key-modal-unique-default-name

Conversation

@dilneiss

@dilneiss dilneiss commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

…re-add

When adding a second API key for the same provider, the backend uses a name-based upsert. Since all new connections defaulted to the name "main", the second key would silently overwrite the first one with no warning to the user.

Changes:

  • Add existingConnectionCount prop threaded from ProviderDetailPageClient through ProviderModalsPanel into AddApiKeyModal
  • Compute a unique default connection name based on existing count to prevent name collision: first connection defaults to "main" (backward compatible), subsequent ones get a numeric suffix ("main-2", "main-3", ...)
  • Properly reset entire form state on modal open (not just baseUrl) to avoid stale field values leaking across opens

Fixes silent data loss when managing multiple API keys for the same provider.

Summary

  • Describe the user-facing or operational change.

Related Issues

  • Closes #
  • Related to #

Validation

  • npm run lint
  • npm run test:unit
  • npm run test:coverage
  • Coverage is still >= 60% for statements, lines, functions, and branches
  • SonarQube PR analysis is green or any remaining issues are explicitly documented below

Tests Added Or Updated

  • List every changed or added automated test file.
  • If no production code changed, state that here.

Coverage Notes

  • If this PR changes src/, open-sse/, electron/, or bin/, explain which tests cover the change.
  • If coverage moved down in any touched file, explain why and what follow-up task will recover it.

Reviewer Notes

  • Call out any risky areas, migrations, feature flags, or manual validation that reviewers should know about.

…re-add

When adding a second API key for the same provider, the backend uses a
name-based upsert. Since all new connections defaulted to the name "main",
the second key would silently overwrite the first one with no warning to
the user.

Changes:
- Add existingConnectionCount prop threaded from ProviderDetailPageClient
  through ProviderModalsPanel into AddApiKeyModal
- Compute a unique default connection name based on existing count to
  prevent name collision: first connection defaults to "main" (backward
  compatible), subsequent ones get a numeric suffix ("main-2", "main-3", ...)
- Properly reset entire form state on modal open (not just baseUrl) to
  avoid stale field values leaking across opens

Fixes silent data loss when managing multiple API keys for the same provider.
@dilneiss
dilneiss requested a review from diegosouzapw as a code owner July 7, 2026 01:10
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

…n overwrite (diegosouzapw#6499)

Sync onto release/v3.8.46. Extracted the pure name derivation to
computeConnectionDefaultName.ts (unit-tested) and trimmed the on-open form
reset to a spread so it doesn't drop the GLM team-quota fields (diegosouzapw#6351) while
keeping the frozen-modal growth minimal (+7).

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.8.46 July 7, 2026 02:58
@diegosouzapw

Copy link
Copy Markdown
Owner

Merged — thank you, @dilneiss! Synced onto release/v3.8.46 with two small adjustments: (1) the pure default-name derivation was extracted to computeConnectionDefaultName.ts and covered by a unit test (main → main-2 → main-3, undefined/negative → main) to satisfy the test gate for UI-only logic; (2) the on-open form reset was kept as a spread ({ ...current, name, baseUrl }) rather than a full field-by-field literal — the literal predated #6351 and would have dropped the new GLM team-quota fields on reopen, and the spread also keeps the frozen modal's growth to +7. Behavior is unchanged: a second key for the same provider gets a unique name so the backend name-based upsert can't overwrite the first connection.

@diegosouzapw
diegosouzapw merged commit 526048d into diegosouzapw:release/v3.8.46 Jul 7, 2026
1 check was pending
This was referenced Jul 7, 2026
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…re-add (diegosouzapw#6499)

Unique default connection name prevents silent overwrite of existing API-key connections. Integrated into release/v3.8.46 with a unit-tested helper; remaining file-size reds are pre-existing base-red drift.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…re-add (diegosouzapw#6499)

Unique default connection name prevents silent overwrite of existing API-key connections. Integrated into release/v3.8.46 with a unit-tested helper; remaining file-size reds are pre-existing base-red drift.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants