Skip to content

fix: parse YAML strings for normalized create bodies#319

Draft
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/harness-mcp-v2-bug-resolution-5205
Draft

fix: parse YAML strings for normalized create bodies#319
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/harness-mcp-v2-bug-resolution-5205

Conversation

@cursor

@cursor cursor Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description

Parse raw YAML string bodies in the shared normalized JSON body builder before dispatching connector/service/environment-style create/update requests. This fixes connector create HTTP 415s when agents pass raw YAML to harness_create instead of a JSON object, while leaving pipeline raw YAML behavior on its separate body path unchanged.

Added integration coverage for connector raw YAML conversion to application/json and local rejection of non-object YAML bodies.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other

Checklist

  • Tests pass
  • Typecheck passes
Open in Web View Automation 

cursoragent and others added 2 commits June 10, 2026 10:26
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I found one important contract issue and one smaller coverage gap against the architecture-review standards.

  1. Important: src/utils/body-normalizer.ts now parses raw YAML for every buildBodyNormalized() consumer, but null-like YAML still bypasses local validation and gets dropped as an absent body instead of failing loudly.
  2. Minor: tests/integration/mock-harness-api.test.ts covers the wrapped connector.create path, but this PR changes a shared helper used by wrapped, unwrapped, and injected-field resources. A focused regression for the null-like YAML case, and ideally one unwrapped-resource path, would better match the contract-test standard.

Assumption:

  • I could not rerun pnpm build / pnpm typecheck / pnpm test in this workspace because node_modules is not installed here, so this review is based on static inspection of the diff and surrounding call sites.

The overall direction looks right: the fix stays out of the separate pipeline raw-YAML path, and the connector JSON-body regression is valuable.

Open in Web View Automation 

Sent by Cursor Automation: Sunil On Demand Architecture Review

body = parseYamlBody(body);
}

if (body !== undefined && body !== null && (typeof body !== "object" || Array.isArray(body))) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Null-like YAML still slips through here. yaml.parse(""), yaml.parse("null"), and yaml.parse("~") return null, which bypasses this guard because it only rejects non-object values when body !== null. The shared builder then returns null, and HarnessClient treats that as an absent body, so connector/service/environment/service_override writes skip the local contract check instead of failing loudly. This should reject null the same way it rejects arrays/scalars, and I’d add a regression for the empty-string / null case.

});
});

it("connector create rejects raw YAML string bodies that do not parse to objects", async () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Worth extending the coverage a bit further here. This PR changes the shared buildBodyNormalized() helper, but the new tests only exercise the wrapped connector.create path plus array-YAML rejection. A small regression for the null-like YAML case ("", "null", "~") and ideally one unwrapped consumer would better match the repo’s “focused coverage for changed body builders” standard.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants