Skip to content

Commit deed51a

Browse files
fix: recurse into NullableSchema.inner in assertValidSchema
assertValidSchema validated array items, record values, and object property schemas but skipped the inner schema of NullableSchema. A misconfigured nested schema like s.nullable(s.object({ x: 'bad' as any })) would silently escape the early construction-time check and only surface a confusing error at invocation time or, worse, produce a repair loop. This adds a nullable branch that recurses into schema.inner before the properties branch, making schema validation consistent for all composite schema types. Discovered while running sample 13-test-plan.ts: the sample uses s.nullable indirectly through s.object with enum fields, and analysing assertValidSchema revealed the gap. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6de6afb commit deed51a

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

skills/rig/rig.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,10 @@ function assertValidSchema(schema: Schema, agentName: string, slot: "input" | "o
16871687
assertValidSchema(schema.additionalProperties, agentName, slot, `${path}.*`);
16881688
return;
16891689
}
1690+
if ("nullable" in schema && schema.nullable === true) {
1691+
assertValidSchema((schema as NullableSchema).inner, agentName, slot, path);
1692+
return;
1693+
}
16901694
if ("properties" in schema) {
16911695
for (const [key, value] of Object.entries(schema.properties) as [string, Schema][]) {
16921696
assertValidSchema(value, agentName, slot, `${path}.${key}`);

src/rig.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ describe("agent", () => {
141141
name: "implicit-nested",
142142
input: s.object({ text: "go" as any }),
143143
})).toThrow(/input\.text/);
144+
145+
expect(() => agent({
146+
name: "implicit-nullable-nested",
147+
output: s.nullable(s.object({ score: "bad" as any })),
148+
})).toThrow(/output\.score/);
144149
});
145150

146151
it("does not expose deprecated hook APIs in core", () => {

0 commit comments

Comments
 (0)