Skip to content

fix(dashboard): handle disabled media model fields - #2199

Closed
changjing9527 wants to merge 1 commit into
TencentCloud:mainfrom
changjing9527:fix/media-generation-disabled-models
Closed

changjing9527 wants to merge 1 commit into
TencentCloud:mainfrom
changjing9527:fix/media-generation-disabled-models

Conversation

@changjing9527

Copy link
Copy Markdown

Summary

Fixes #2100.

When either image or video generation is disabled in the provider modal, its model field is conditionally unmounted. providerFromForm() still called .trim() unconditionally, so undefined.trim() threw and the catch block silently returned null. Saving, credential verification, and model tests therefore appeared to do nothing.

This change:

  • normalizes optional model form values with a safe empty-string fallback;
  • keeps the API's string fields valid when a capability is disabled;
  • adds regression coverage for both disabled image and disabled video paths.

Validation

  • vitest run src/pages/Settings/MediaGeneration/index.test.ts — 2 passed
  • ESLint on the changed files — passed
  • Prettier check on the changed files — passed
  • tsc -b was attempted; the repository currently lacks existing dependencies (dayjs, unified, pdfjs-dist, @ant-design/icons), so the full project check remains environment-blocked.

@jubaoliang

Copy link
Copy Markdown
Collaborator

Closing as superseded by #2105 (same issue #2100).

Why keep #2105 instead:

  • Targets develop (this PR targets main, which is not the default for bugfixes)
  • Preserves configured image/video models when the tool switches are off (reads from the full form store), instead of blanking them with ?? ""
  • Includes focused unit tests around the unmount/.trim() crash

Please continue on #2105. Thanks for the report and the initial fix attempt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants