Skip to content

Fix unresolved OpenAPI references - #135

Closed
mikemikimike wants to merge 2 commits into
agi-inc:mainfrom
mikemikimike:agent/fix-openapi-ref-cleanup
Closed

mikemikimike wants to merge 2 commits into
agi-inc:mainfrom
mikemikimike:agent/fix-openapi-ref-cleanup

Conversation

@mikemikimike

Copy link
Copy Markdown

Fixes #133

The endpoint generator used Array.prototype.pop on temp.properties, which is a plain object, and used map for side effects. This caused unresolved references to crash generation instead of being removed.

This change extracts resolveRef into a testable helper, uses forEach and delete for unresolved properties, and adds a Node regression test.

Validation:

  • npm run test:generateEndpoints
  • node --check scripts/resolveRef.mjs
  • node --check scripts/resolveRef.test.mjs

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 70d3394e-b887-404c-949a-4de838bc1718

📥 Commits

Reviewing files that changed from the base of the PR and between 6f4485e and 103b25b.

📒 Files selected for processing (2)
  • apps/agentprotocol.ai/scripts/resolveRef.mjs
  • apps/agentprotocol.ai/scripts/resolveRef.test.mjs
📜 Recent review details
🔇 Additional comments (2)
apps/agentprotocol.ai/scripts/resolveRef.mjs (1)

1-27: LGTM!

apps/agentprotocol.ai/scripts/resolveRef.test.mjs (1)

28-48: LGTM!


📝 Walkthrough

Walkthrough

The change adds a recursive resolveRef utility for schema references. It removes unresolved properties and preserves valid references. The endpoint generator now uses the utility for request-body schemas. Generated properties no longer include trailing commas. A Node test and package script validate reference resolution.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: fixing unresolved OpenAPI references.
Description check ✅ Passed The description directly explains the OpenAPI generation crash, the fix, and the added regression test.
Linked Issues check ✅ Passed The changes replace Object.pop with delete, use forEach, and add reference-resolution tests, satisfying issue #133.
Out of Scope Changes check ✅ Passed The helper extraction, recursive reference handling, script update, and regression tests support the linked issue objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/agentprotocol.ai/scripts/resolveRef.mjs

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

apps/agentprotocol.ai/scripts/resolveRef.test.mjs

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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 `@apps/agentprotocol.ai/scripts/resolveRef.mjs`:
- Around line 7-14: Update resolveRef and its recursive property traversal to
track references in the active resolution path, preserving the original $ref
when a reference would create a cycle instead of recursing further. Keep
non-cyclic references fully expanded and retain deletion of unresolved
references, then add a regression test covering a self-referential schema such
as Node.properties.next -> Node.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f595930a-eed7-4c65-a8be-f89ace433906

📥 Commits

Reviewing files that changed from the base of the PR and between 5047199 and 6f4485e.

📒 Files selected for processing (4)
  • apps/agentprotocol.ai/package.json
  • apps/agentprotocol.ai/scripts/generateEndpoints.mjs
  • apps/agentprotocol.ai/scripts/resolveRef.mjs
  • apps/agentprotocol.ai/scripts/resolveRef.test.mjs
📜 Review details
🔇 Additional comments (4)
apps/agentprotocol.ai/scripts/resolveRef.mjs (1)

1-5: LGTM!

apps/agentprotocol.ai/scripts/resolveRef.test.mjs (1)

1-26: LGTM!

apps/agentprotocol.ai/scripts/generateEndpoints.mjs (1)

4-4: LGTM!

Also applies to: 25-25, 44-44, 75-75

apps/agentprotocol.ai/package.json (1)

10-10: LGTM!

Comment thread apps/agentprotocol.ai/scripts/resolveRef.mjs Outdated
@mikemikimike

Copy link
Copy Markdown
Author

Validation

  • Resolver regression suite: node --test scripts/resolveRef.test.mjs — 2 passed.
  • Repository CI command: npm run ci — blocked by the existing repository-wide Prettier baseline (65 files reported), before ESLint runs. No changed-file functional test failures were reported.

The recursive $ref regression is covered by the new test.

@mikemikimike
mikemikimike deleted the agent/fix-openapi-ref-cleanup branch August 2, 2026 02:16
@mikemikimike
mikemikimike restored the agent/fix-openapi-ref-cleanup branch August 2, 2026 11:23
@mikemikimike mikemikimike reopened this Aug 2, 2026
@mikemikimike
mikemikimike deleted the agent/fix-openapi-ref-cleanup branch August 31, 2026 12:50
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.

Unhandled TypeError in OpenAPI generation script (Object.pop is not a function)

1 participant