Skip to content

fix(web): accept a single API key for Baidu YiYan - #18611

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/baidu-yiyan-single-api-key
Aug 21, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/baidu-yiyan-single-api-key

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix(web): accept a single API key for Baidu YiYan

The backend now allows a plain YiYan API key instead of an AK/SK pair, so the provider form no longer needs two separate credential fields.

The backend now allows a plain YiYan API key instead of an AK/SK pair,
so the provider form no longer needs two separate credential fields.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Aug 21, 2026
@dcc123456
dcc123456 requested a review from wangq8 August 21, 2026 07:02
@dcc123456 dcc123456 added the ci Continue Integration label Aug 21, 2026
@dcc123456
dcc123456 marked this pull request as draft August 21, 2026 07:02
@dcc123456
dcc123456 marked this pull request as ready for review August 21, 2026 07:03
@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f2c59b3-5372-488f-84d5-20f7870e5400

📥 Commits

Reviewing files that changed from the base of the PR and between 1f7be63 and 4cf2d9c.

📒 Files selected for processing (1)
  • web/src/pages/user-setting/setting-model/provider-schema/field-config/provider-config-map.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Baidu YiYan configuration now uses one password api_key field. Verification and submission pass this value directly. The previous yiyan_ak and yiyan_sk fields, structured payload, and echo transformation were removed.

Changes

Baidu YiYan API key flow

Layer / File(s) Summary
API key field and submission flow
web/src/pages/user-setting/setting-model/provider-schema/field-config/provider-config-map.ts
Baidu YiYan now uses one password api_key input. Verification and submission pass the API key string directly.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 4cf2d

This localized change updates the Baidu YiYan provider form to accept a single API key; no actionable merge-blocking risk remains beyond normal checks and review.

Poem

I’m a rabbit with a key in my paw,
One API secret is all that I saw.
No AK, no SK,
Just one clean way,
YiYan hops forward without a flaw.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description includes the required Summary section and clearly explains the provider form change and its backend context.
Title check ✅ Passed The title clearly and concisely describes the main change: accepting a single API key for Baidu YiYan.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! The change correctly aligns the frontend with the backend's single access-token support — BaiduYiyanChat / BaiduYiyanEmbed / BaiduYiyanRerank now fall back to access_token when the stored key isn't a JSON object. The core change looks good, and switching the field to Password is a nice security improvement.

One thing I'd like you to double-check — backward compatibility for existing instances.

The PR removes echoTransform entirely. For instances saved in the legacy {"yiyan_ak": ..., "yiyan_sk": ...} JSON format, the generic echo fallback (unwrapApiKey in web/src/pages/user-setting/setting-model/instance-card/hooks.tsx) only recognizes a bare string or a literal api_key key inside the JSON object. For the yiyan_ak shape it returns api_key: ''.

As a result, opening and saving an existing AK/SK instance (e.g. just renaming it or changing base_url) will submit an empty api_key and silently clear the stored credential — the api_key field is hidden via hideWhenInstanceExists and is never re-populated from the legacy shape.

Suggested fix: keep a small echoTransform that maps the legacy object back to the single key, e.g.:

echoTransform: (instance) => {
  const obj = parseApiKeyAsObject(instance.api_key);
  if (obj && typeof obj.yiyan_ak === 'string') {
    return { api_key: obj.yiyan_ak };
  }
  return { api_key: typeof instance.api_key === 'string' ? instance.api_key : '' };
},

(or otherwise handle migration of legacy instances).

Minor / non-blocking: the now-unused i18n keys (addyiyanAK, yiyanAKMessage, addyiyanSK, yiyanSKMessage) remain in the locale files — could be cleaned up in a follow-up.

Otherwise LGTM.

@wangq8 wangq8 added ci Continue Integration and removed ci Continue Integration labels Aug 21, 2026
@wangq8
wangq8 merged commit 1a0c896 into infiniflow:main Aug 21, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants