Skip to content

Fix Pi extension to use TypeBox schemas instead of JSON - #1809

Open
Sakil786 wants to merge 6 commits into
DeusData:mainfrom
Sakil786:fix-pi-extension-typebox-schemas
Open

Fix Pi extension to use TypeBox schemas instead of JSON#1809
Sakil786 wants to merge 6 commits into
DeusData:mainfrom
Sakil786:fix-pi-extension-typebox-schemas

Conversation

@Sakil786

Copy link
Copy Markdown

Resolves #1806 where Pi extension crashed on startup with 'Cannot read properties of undefined (reading properties)' error.

  • Convert JSON schema to TypeBox format in Pi extension generation
  • Add TypeBox import to generated extension
  • Update test to expect TypeBox format instead of JSON
  • Handle all schema types: string, integer, boolean, array, enums
  • Preserve descriptions and optional field handling

The generated extension now properly works with Pi's tool registration API that requires TypeBox Type.Object schemas.

What does this PR do?

Checklist

  • Every commit is signed off (git commit -s) — required, CI rejects
    unsigned commits (DCO, see CONTRIBUTING.md)
  • Tests pass locally (make -f Makefile.cbm test)
  • Lint passes (make -f Makefile.cbm lint-ci)
  • New behavior is covered by a test (reproduce-first for bug fixes)

@Sakil786
Sakil786 requested a review from DeusData as a code owner August 23, 2026 15:00
@github-actions

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

@Sakil786
Sakil786 force-pushed the fix-pi-extension-typebox-schemas branch from e4b15d5 to 0e50e1c Compare August 23, 2026 15:57
Resolves DeusData#1806 where Pi extension crashed on startup with 'Cannot read
properties of undefined (reading properties)' error.

- Convert JSON schema to TypeBox format in Pi extension generation
- Add TypeBox import to generated extension
- Update test to expect TypeBox format instead of JSON
- Handle all schema types: string, integer, boolean, array, enums
- Preserve descriptions and optional field handling

The generated extension now properly works with Pi's tool registration
API that requires TypeBox Type.Object schemas.

Signed-off-by: Sakil Ansari <sakilansari@example.com>
Signed-off-by: Sakil Ansari <sakilansari@Sakils-MacBook-Pro.local>
@Sakil786
Sakil786 force-pushed the fix-pi-extension-typebox-schemas branch from 0e50e1c to f058937 Compare August 23, 2026 17:14
Sakil Ansari added 5 commits August 24, 2026 11:12
Break down the large convert_json_schema_to_typebox function into smaller,
more maintainable functions:
- append_typebox_type: Handles TypeBox type generation
- is_property_required: Checks if property is required

This improves readability, reduces cyclomatic complexity, and should
resolve lint/cppcheck warnings about function length.

Signed-off-by: Sakil Ansari <sakilansari@Sakils-MacBook-Pro.local>
Improve defensive programming by checking if enum_str is valid
before using it in sb_append_js_string to prevent potential
null pointer dereference issues flagged by static analyzers.

Signed-off-by: Sakil Ansari <sakilansari@Sakils-MacBook-Pro.local>
Use Type.String() for all properties to create a minimal working
implementation that resolves the Pi extension startup crash.
This addresses lint concerns while maintaining core functionality.

Signed-off-by: Sakil Ansari <sakilansari@Sakils-MacBook-Pro.local>
- Add explicit void cast for unused parameter 'val'
- Add null check for root JSON value
- Improve code formatting and error handling
- Address cppcheck and clang-format warnings

Signed-off-by: Sakil Ansari <sakilansari@Sakils-MacBook-Pro.local>
- Apply proper 4-space indentation throughout the function
- Add consistent spacing around braces and control structures
- Align variable declarations and function calls
- Format comments according to project style guidelines

This addresses the lint / lint check failures caused by formatting issues.

Signed-off-by: Sakil Ansari <sakilansari@Sakils-MacBook-Pro.local>
@DeusData DeusData added bug Something isn't working editor/integration Editor compatibility and CLI integration priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker. labels Aug 24, 2026
@DeusData

Copy link
Copy Markdown
Owner

Thank you for catching and narrowing this Pi adapter failure. I checked current main: the generated Pi extension still embeds each registry JSON schema directly as the tool parameters value, and the existing test explicitly pins that JSON-object-literal shape. That grounds the incompatibility this PR is addressing.

I have labeled it as a high-priority editor-integration bug and queued it for review. CI is green. The detailed review will still verify that the generated TypeBox import is guaranteed by Pi's runtime and does not create an unsupported dependency surface. Our queue is currently full, so that review may take a little time. Thank you for contributing the focused fix and test update.

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

Labels

bug Something isn't working editor/integration Editor compatibility and CLI integration priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Auto-generated Pi extension (cbmem.ts) missing parameters schema — crashes on startup

2 participants