Skip to content

fix: show header-specific MCP validation errors - #17966

Merged
enyst merged 1 commit into
OpenHands:mainfrom
pei711:fix/mcp-header-validation-message
Oct 11, 2026
Merged

enyst merged 1 commit into
OpenHands:mainfrom
pei711:fix/mcp-header-validation-message

Conversation

@pei711

@pei711 pei711 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:
我检查了修复前后的运行截图,确认错误提示从环境变量改为请求头格式。


AGENT:
Fixed MCP server form validation so malformed Header authentication lines show a header-specific message, while STDIO environment validation keeps its existing message. Added the translation key in all 15 supported locales and a regression test. The .pr/bugs/ screenshots show the same production-built UI before and after the fix.

Why

Header authentication reuses the KEY=value validator for environment variables, so malformed header lines incorrectly report an environment-variable error.

Summary

  • Allow the shared KEY=value validator to receive its message key and use a dedicated header-format key for Header authentication.
  • Add the header-specific copy in all supported locales and a regression test covering the Header and STDIO paths.

Issue Number

Fixes #17958

How to Test

  • npx vitest run __tests__/components/features/settings/mcp-settings/mcp-server-form.validation.test.tsx — 12 tests passed.

  • npm run make-i18n and npm run check-translation-completeness — passed.

  • npm run build:app — passed; launched the production build with node bin/agent-canvas.mjs --port 18321 and reproduced malformed NOEQUALS header input in the real MCP editor.

  • npm run lint — passed with existing warnings outside this change.

  • npm test -- --reporter=dot — 8,057 passed, 33 skipped, 7 todo; 10 failed across 7 files due Windows-specific path/platform assumptions in unrelated tests (for example, POSIX-only absolute-path expectations and a platform-name assertion).

  • GitHub CI at commit 07b762b6e: Ubuntu and Windows test-and-build checks passed, along with PR description, title, and screenshot artifact checks. CI run.

Video/Screenshots

Before fix, the malformed Header auth input displayed the environment-variable error:

Before fix: malformed MCP Header auth shows environment-variable error

After fix, the same input displays the header-specific validation message:

After fix: malformed MCP Header auth shows header-specific error

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

Validation behavior and parsing are unchanged; this only selects the correct localized error message.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Artifact Cleanup Queued

The .pr/ directory reached main after merge. A cleanup PR has been opened or updated: #17718

@github-actions github-actions Bot added the type: fix A bug fix label Oct 5, 2026
@pei711
pei711 marked this pull request as ready for review October 5, 2026 05:58
@pei711

pei711 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

The MCP validation fix is ready for review: Ubuntu/Windows test-and-build, description, title, and artifact checks pass. The focused MCP validation suite also passes all 12 tests locally.

After marking the PR ready, the separate release ready workflow failed before starting any jobs: the caller grants contents: read, while the reusable workflow's freeze and release-test-dispatch-event jobs require contents: write. This PR does not change workflows. The base-repository workflow permission mismatch needs maintainer attention: https://github.com/OpenHands/OpenHands/actions/runs/37270127291

@all-hands-bot all-hands-bot 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.

This review was posted by an AI agent (OpenHands).

Scope

Canvas-owned UI/i18n change (form validation message selection + src/i18n/translation.json). It belongs in OpenHands/OpenHands; no Agent Server contract, wire, or durable-state change is involved.

Assessment

The fix threads an optional errorKey through the shared validateEnvFormat helper and passes SETTINGS$MCP_ERROR_HEADER_INVALID_FORMAT from the Header branch, while the STDIO env call at line 245 keeps the default SETTINGS$MCP_ERROR_ENV_INVALID_FORMAT. The parameter is optional and defaults to the previous value, so parsing and all other callers are unchanged — the only behavioral delta is the selected message, which is exactly the reported defect.

Verified on the current head 07b762b6e9b74efaaadb04ebc544e4e3cf31088f:

  • New i18n key present with all 15 supported locales; npm run make-i18n and npm run check-translation-completeness both pass.
  • __tests__/components/features/settings/mcp-settings/mcp-server-form.validation.test.tsx — 12/12 pass. The new case drives the real validator (no mock of the validation logic) and asserts the header key appears while the env key does not, so it fails if the header key stops being passed.
  • __tests__/i18n/translation-completeness.test.ts — 10/10 pass (covers the new key's locale coverage and no English-copy regressions).
  • GitHub Actions for this head: test-and-build (ubuntu) and test-and-build (windows) success, check-pr-artifacts success, and the latest Validate PR description runs (05:58) success. The two earlier Validate PR description failures (04:19/04:20) are superseded by the later passing runs on the same head.

Acceptance criteria checklist (#17958)

  • Malformed Header-auth line shows a header-specific message — SETTINGS$MCP_ERROR_HEADER_INVALID_FORMAT now passed from the Header branch.
  • Empty Headers field still shows SETTINGS$MCP_ERROR_HEADER_REQUIRED — that branch is untouched.
  • Valid KEY=value header still submits and is stored under auth.headers unchanged — parsing is untouched; the existing submit test passes.
  • STDIO env validation still shows SETTINGS$MCP_ERROR_ENV_INVALID_FORMAT — default key preserved; existing env test passes.
  • Header-format message present in all 15 locales, and generation/completeness checks pass.
  • Regression test extended so Header asserts the header message and STDIO keeps the env message; suite passes.

Notes

  • Production evidence: the before/after screenshots under .pr/bugs/ exercise the same production entry point described in the issue reproduction. A still screenshot is the correct artifact type here, since the changed behavior is a static rendered message.
  • The .pr/ artifacts are temporary and are cleaned up by repo automation after merge; no action required.
  • Eval risk: none. This selects a localized string only; no prompt, tool-selection, conversation-payload, planning, memory, or evaluation path changes.

✅ APPROVED

@all-hands-bot all-hands-bot 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.

Reusing validateEnvFormat with an errorKey parameter is the right minimal refactor, and the new key is present in all 15 locales. The test asserts the header-specific message shows and the env message doesn't. Approving.

This review was posted by an AI agent (OpenHands) on behalf of the requester.

@enyst enyst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@enyst
enyst merged commit 7889d8f into OpenHands:main Oct 11, 2026
31 of 33 checks passed
@openhands-release-bot openhands-release-bot Bot added the released: v1.27.0 Shipped in v1.27.0 label Oct 12, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in v1.27.0.

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

Labels

released: v1.27.0 Shipped in v1.27.0 type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Custom MCP server editor reports a malformed header as an environment-variable error

3 participants