Skip to content

Assert type: object so a parameter class is actually named - #38

Open
CNSeniorious000 wants to merge 1 commit into
mainfrom
run-parameter-classes
Open

Assert type: object so a parameter class is actually named#38
CNSeniorious000 wants to merge 1 commit into
mainfrom
run-parameter-classes

Conversation

@CNSeniorious000

@CNSeniorious000 CNSeniorious000 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

#31 borrowed dsh's render context to name parameter objects instead of degrading them to dict[str, Any]. It works — but only when the caller happens to put type: 'object' on the parameters schema. Without it dsh degrades the whole args type and every parameter goes back to Any, silently.

no type key                          -> window: dict[str, Any]
type: object                         -> window: ReadArgsWindow
type: object + additionalProperties  -> window: ReadArgsWindow

That is the third trigger of the same silent degradation, after a stray $schema and a oneOf at any property — and the only one reached by omission rather than by content. A schema that declares properties is describing an object whether or not it says so; JSON Schema has no other reading. So it is asserted rather than assumed, spread first so a schema that does declare a type keeps its own:

const asObject = (parameters) => ('properties' in parameters ? { type: 'object', ...parameters } : parameters)

How it was caught, and the gap that let it through

the rendered block is a program is the only test that RUNS the fence, and therefore the only place a class that is referenced but never declared can show up — an annotation has to evaluate. Its catalogue had no object-typed parameter, so #31's classes were never executed by it; everything that did cover them read the text.

This adds one, and asserts through the interpreter:

read.__annotations__["window"].__name__   // -> ReadArgsWindow

That fixture's parameters carry no type key — which is why the new assertion failed on its first run instead of passing quietly. The fixture style is what exposed the bug.

One expectation moved on purpose

narrowing only removes a reason to reject asserted rows: list[dict[str, Any]]. That spelling is the degradation #31 exists to remove, so it now reads rows: list[KeepArgsRows]. The other three spellings in that loop are the actual guard — narrowed must not touch a type dsh already accepts — and they are unchanged.

Verification

Mutation-checked: dropping asObject fails both the new fence assertion and the rows one.

@sourcery-ai sourcery-ai 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.

Sorry @CNSeniorious000, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 4 days and 16 hours by commenting @sourcery-ai review. Upgrade to get a review now.

Repository owner deleted a comment from chatgpt-codex-connector Bot Sep 1, 2026
Repository owner deleted a comment from coderabbitai Bot Sep 1, 2026
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.

1 participant