Skip to content

[WRONG BRANCH] fix(kiro): preserve property names when flattening root composition - #277

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-kiro-schema-sanitization
Draft

[WRONG BRANCH] fix(kiro): preserve property names when flattening root composition#277
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-kiro-schema-sanitization

Conversation

@luvs01

@luvs01 luvs01 commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Fix a regression where root-composition flattening treated property-name maps as ordinary schema objects, causing legitimate property names such as format and pattern to be dropped by the Kiro sanitizer.

Description

  • Use sanitizeSchemaMap(...) (schema-map-aware recursion) instead of sanitizeKiroSchema(...) when merging properties from the root and from root composition variants inside ensureRootObjectType, so property names are preserved while their child schemas are still sanitized.
  • Add a focused regression test in tests/kiro-adapter.test.ts that verifies property names that collide with rejected validation keywords survive root oneOf flattening and that nested validation-only keywords are still stripped.

Testing

  • Ran the focused adapter tests with bun test tests/kiro-adapter.test.ts and the updated kiro tests passed (54 tests across that file).
  • Ran type checking with bun x tsc --noEmit and it succeeded.
  • Attempted the full test run (bun run test), which exercised the broader suite but encountered unrelated environment-sensitive timeouts and integration failures; these are not caused by this small sanitizer change and do not affect the focused regression coverage added here.

Codex Task

Summary by CodeRabbit

  • Bug Fixes

    • Fixed schema processing for properties named format or pattern, ensuring they remain available while conflicting validation metadata is handled correctly.
    • Preserved required-property validation when flattening affected schemas.
  • Tests

    • Added coverage for schema properties that share names with reserved validation keywords.

@github-actions github-actions Bot added the bug Something isn't working label Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The adapter now preserves schema property names that match rejected keywords while recursively sanitizing each property schema. Tests cover root and oneOf schema flattening, validation metadata removal, and required-property preservation.

Changes

Schema sanitization

Layer / File(s) Summary
Property map sanitization and regression coverage
src/adapters/kiro-tools.ts, tests/kiro-adapter.test.ts
Root and composed-schema properties now use sanitizeSchemaMap. The test confirms that format and pattern remain property names, their rejected validation metadata is removed, and the root required list remains intact.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Mergeability Score: 🔵 Low · up to f60a0

The sanitizer can still drop a schema property literally named proto, altering affected schemas before they reach Kiro. This is a bounded edge-case correctness risk, so the PR is mergeable with explicit owner awareness or follow-up.

Suggested reviewers: lidge-jun, ingwannu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving property names during Kiro root-composition flattening.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/propose-fix-for-kiro-schema-sanitization

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

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot changed the title fix(kiro): preserve property names when flattening root composition [WRONG BRANCH] fix(kiro): preserve property names when flattening root composition Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 13, 2026 02:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/adapters/kiro-tools.ts`:
- Line 106: Preserve a literal __proto__ schema property by using null-prototype
objects for the output of sanitizeSchemaMap and the props objects receiving its
entries, or define assignments as own properties with Object.defineProperty.
Update both affected Object.assign paths and add a regression case alongside
format and pattern confirming __proto__ reaches Kiro unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c3e8299c-ffde-4991-a323-1895134e9c15

📥 Commits

Reviewing files that changed from the base of the PR and between 1193075 and f60a04d.

📒 Files selected for processing (2)
  • src/adapters/kiro-tools.ts
  • tests/kiro-adapter.test.ts

// { type:"object", properties:{path}, required:["path"], oneOf:[...] } keeps them.
if (obj.properties && typeof obj.properties === "object") {
Object.assign(props, sanitizeKiroSchema(obj.properties) as Record<string, unknown>);
Object.assign(props, sanitizeSchemaMap(obj.properties) as Record<string, unknown>);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

bun - <<'BUN'
const source = JSON.parse('{"__proto__":{"type":"string"}}');
const out = {};

for (const [name, child] of Object.entries(source)) {
  out[name] = child;
}

if (Object.hasOwn(out, "__proto__")) {
  throw new Error("The reproduction did not expose the key-loss behavior");
}

console.log("Reproduced: __proto__ is not an own property.");
BUN

Repository: luvs01/opencodex

Length of output: 195


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- src/adapters/kiro-tools.ts ---'
sed -n '45,135p' src/adapters/kiro-tools.ts

printf '%s\n' '--- JavaScript special-key reproduction ---'
node - <<'JS'
const source = JSON.parse('{"__proto__":{"type":"string"}}');
const out = {};
for (const [name, child] of Object.entries(source)) out[name] = child;

console.log({
  sourceOwnProperty: Object.hasOwn(source, "__proto__"),
  outputOwnProperty: Object.hasOwn(out, "__proto__"),
  outputPrototype: Object.getPrototypeOf(out),
  outputPrototypeType: Object.getPrototypeOf(out)?.type,
});
JS

Repository: luvs01/opencodex

Length of output: 4853


Preserve __proto__ as a schema property name.

At src/adapters/kiro-tools.ts:106 and :121, Object.assign writes sanitized entries into normal props. sanitizeSchemaMap also writes entries into normal out at line 64. If the input contains properties.__proto__, the assignment invokes the prototype setter. The schema property is lost before Kiro receives the schema.

Use Object.create(null) for both out and props, or define entries with Object.defineProperty. Add a regression case for __proto__ beside format and pattern.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/adapters/kiro-tools.ts` at line 106, Preserve a literal __proto__ schema
property by using null-prototype objects for the output of sanitizeSchemaMap and
the props objects receiving its entries, or define assignments as own properties
with Object.defineProperty. Update both affected Object.assign paths and add a
regression case alongside format and pattern confirming __proto__ reaches Kiro
unchanged.

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

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant