Skip to content

fix(ui): support string-object unions in config form schema#31762

Closed
liuxiaopai-ai wants to merge 1 commit intoopenclaw:mainfrom
liuxiaopai-ai:codex/config-form-union-31490
Closed

fix(ui): support string-object unions in config form schema#31762
liuxiaopai-ai wants to merge 1 commit intoopenclaw:mainfrom
liuxiaopai-ai:codex/config-form-union-31490

Conversation

@liuxiaopai-ai
Copy link

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: Config Form mode marks models.providers unsupported when apiKey uses SecretInputSchema (string | object union), causing the whole provider section to collapse to Raw-only.
  • Why it matters: users cannot edit provider config fields in Form mode for common setups.
  • What changed: the schema analyzer now preserves/normalizes non-literal unions (including string+object), and the form renderer now resolves mixed string/object unions to a concrete variant based on current value/default.
  • What did NOT change (scope boundary): raw config semantics and secret ref schema definitions are unchanged; this is a form-analysis/render compatibility fix only.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • models.providers is now editable in Config Form mode when provider apiKey schema is string | secret-ref object.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS (local)
  • Runtime/container: Node 22 + pnpm
  • Model/provider: schema-level test for providers map with secret-style apiKey union
  • Integration/channel (if any): Control UI config form
  • Relevant config (redacted): models.providers.<id>.apiKey as string | {source,name}

Steps

  1. Analyze config schema containing models.providers.*.apiKey with anyOf: [string, object].
  2. Confirm analyzer output does not mark models.providers unsupported.
  3. Confirm form renderer can resolve string/object union variants.

Expected

  • No unsupported marker for models.providers due to this union pattern.

Actual

  • Matches expected with new unit regression and UI schema handling updates.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • pnpm test src/config/config-form-analyze.union.test.ts
    • pnpm exec oxfmt --check ui/src/ui/views/config-form.analyze.ts ui/src/ui/views/config-form.node.ts ui/src/ui/config-form.browser.test.ts src/config/config-form-analyze.union.test.ts
  • Edge cases checked:
    • direct string|object unions no longer marked unsupported
    • nested models.providers.*.apiKey union no longer escalates unsupported state to models.providers
  • What you did not verify:
    • browser-rendered integration test execution in this environment (existing browser-test harness is not part of default include)
    • full pnpm check currently fails on pre-existing unrelated tsgo errors in src/process/exec.windows.test.ts and src/slack/monitor/events/messages.ts

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit fix(ui): support string-object schema unions in config form.
  • Files/config to restore: ui/src/ui/views/config-form.analyze.ts, ui/src/ui/views/config-form.node.ts.
  • Known bad symptoms reviewers should watch for: fields showing unsupported union fallbacks in form mode.

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk: broader union normalization could unintentionally make genuinely unsafe unions appear editable.
    • Mitigation: normalization still propagates child unsupported paths; regression tests specifically cover the SecretInput-style safe union path.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64fa2b46f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

};
}

if (remaining.length > 0 && literals.length === 0) {

Choose a reason for hiding this comment

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

P2 Badge Preserve unsupported flag for unions the renderer cannot resolve

This new branch treats every non-literal union as form-editable, but renderNode still only resolves a few union shapes (literals, primitive-only unions, and the new string+object special case). A concrete schema path in this repo, TelegramAccountSchema.capabilities (array | object in src/config/zod-schema.providers-core.ts), now drops out of unsupportedPaths, yet rendering still falls through to Unsupported type: undefined because no variant is selected. That regresses analysis accuracy and hides form-unsafe status for real config sections.

Useful? React with 👍 / 👎.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Added support for string | object union schemas (including SecretInputSchema) in Config Form mode. Previously, fields like models.providers.*.apiKey with anyOf: [string, {object}] were marked as unsupported, forcing the entire provider section into Raw-only mode. The analyzer now normalizes non-literal unions while preserving child unsupported paths, and the renderer resolves mixed unions to a concrete variant based on the current value (defaulting to string for undefined/null values, object for object values).

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-scoped to form-layer schema analysis and rendering only, with no modifications to config semantics or secret handling. The implementation correctly normalizes union schemas and resolves to appropriate variants based on runtime values, with comprehensive test coverage for the SecretInput pattern and browser rendering scenarios. The logic properly propagates unsupported child paths and maintains backward compatibility.
  • No files require special attention

Last reviewed commit: 64fa2b4

@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Thanks for the contribution here. I’m closing this as a duplicate of #31866 for the same bug scope.

Why this is being closed:

  • Scope overlap: models.providers SecretInput union support in config form analyzer
  • Canonical PR fix(ui): handle SecretInput union in config form analyzer #31866 already covers this path and is the one we’re tracking to land.
  • Keeping one PR per bug avoids split review feedback, conflicting rebases, and duplicated CI churn.

What helped from this PR:

  • Your changes validated the root cause and fix direction.
  • The implementation details here were reviewed and compared during triage.

If you want, you can still port any unique idea from this branch into #31866 via a focused follow-up commit.

Specific triage note:
#31866 focuses exactly on SecretInput union normalization in analyze path without extra unrelated surface area.

@steipete steipete closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Config Form view marks models.providers as unsupported due to SecretInputSchema union

2 participants