Skip to content

unwrapBodyParam's body-field check is blind to schema composition #64

Description

@AlexKantor87

The check that stops unwrapBodyParam from clobbering a request body with a field called body reads schema.properties directly:

const schema = entry.requestBody[0]?.schema;
const properties = schema?.properties;
if (properties && typeof properties === "object" && "body" in properties) return params;

src/tools/execute-action.ts:49-51.

The generator inlines $refs but copies composition through untouched, so a field can be declared inside an allOf member instead. Two catalog entries already carry a root-level allOf (create_artifact, post_override_attestation), so the shape is in use.

What would go wrong: a regenerated catalog declares a field named body inside a composition branch. A caller sends params: { body: {...} } meaning that field. The check does not find it, unwraps anyway, and the object is flattened. Its inner keys go out as sibling top-level params and the body field never arrives. Nothing fails.

No catalog entry declares such a field today, so this is a forward risk rather than a live bug.

PR #63 added a bodyFields helper to test/catalog.test.ts that walks composition. Fixing this means moving that helper into src/ and having both callers use it, so one function decides what a request body declares.

Found while reviewing #63.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions