fix(protocol): preserve provider import JSON values#17168
Merged
0xfullex merged 2 commits intoJul 21, 2026
Conversation
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> Signed-off-by: VectorPeak <[email protected]>
VectorPeak
force-pushed
the
fix/provider-import-json-values
branch
from
July 18, 2026 14:32
61dc011 to
ee33126
Compare
kangfenmao
approved these changes
Jul 19, 2026
DeJeune
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Before this PR:
Provider import deep links decoded the
dataquery value and immediately ran the decoded payload through the legacy cleanup path beforeJSON.parse:That kept legacy wrapped payloads like
({'id':'custom-openai'})working, but the same cleanup also touched valid JSON string values. A standard JSON import payload containing a provider name such asBob's OpenAI (EU)could be rewritten before parsing and fail instead of opening the provider settings flow.After this PR:
Provider import decoding now treats standard JSON as the primary format.
parseProvidersImportDatafirst parses the decoded payload as-is, then falls back to the legacy cleanup path only if standard JSON parsing fails. This preserves apostrophes and parentheses inside valid JSON strings while keeping the existing wrapped/single-quote payload behavior covered by the test suite.Why we need it and why it was done in this way
What Problem This Solves
parseProvidersImportDatasits on the provider-import deep-link path:The bug was not in base64 decoding or settings navigation. It was the ordering inside
parseProvidersImportData: a lossy legacy normalization step ran before the parser had a chance to accept already-valid JSON.A valid JSON object can contain apostrophes and parentheses inside string values. For example, this provider name is valid JSON:
{ "id": "custom-openai", "name": "Bob's OpenAI (EU)" }Before this PR, the decoded JSON text was rewritten into invalid JSON because the apostrophe became a double quote and the parentheses were removed:
That means a normal provider import link could fail at parse time before the settings import screen receives
addProviderData.Changes
The fix keeps the change local to
parseProvidersImportData, where the provider import payload is already decoded and normalized. It intentionally does not change provider deep-link query handling for+and/, settings navigation, or the legacy wrapped payload fallback.Evidence
The new regression test covers the standard JSON payload that previously went through lossy cleanup:
The existing compatibility test still covers the legacy wrapped payload:
Validation performed:
Result:
5 passed.Remote CI after the final push:
Possible call chain / impact
This PR only changes how provider import payload text is parsed after base64 decoding. It does not change MCP install links, navigate links, OAuth callbacks, renderer-side provider settings behavior, or the existing provider import handling for standard base64
+and/characters.Breaking changes
NONE
Special notes for your reviewer
Validation performed:
git diff --checknode node_modules/vitest/vitest.mjs run --project main src/main/services/protocol/handlers/__tests__/providersImport.test.ts --reporter=verbose- 5 tests passedLocal note: the normal
pnpm test:main src/main/services/protocol/handlers/__tests__/providersImport.test.tspath initially attempted to complete dependency installation and timed out fetchingonnxruntime-node, so the focused Vitest run above was used after resolving the local test binary.Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
mainfor active development,v1for v1 maintenance fixes/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note