Skip to content

[Bug]: agent: skeletonFromJsonSchema ignores array form type (nullable types always return null) #614

Description

@Sertug17

Affected package or area

@sapiom/agent packages/agent/src/introspection.ts, skeletonFromJsonSchema

Affected version, release, or commit

latest main (3cbe957)

Environment

Any pure TypeScript logic, no platform dependency

Minimal reproduction and steps

  1. Define an agent with a nullable input field, e.g. z.string().nullable()
  2. Zod generates JSON Schema: { type: ["string", "null"] }
  3. skeletonFromJsonSchema receives { type: ["string", "null"] }
  4. switch(schema.type) receives an array no case matches
  5. Falls through to default: return null

Expected behavior

skeletonFromJsonSchema({ type: ["string", "null"] }) returns "" (the non-null type's skeleton)
skeletonFromJsonSchema({ type: ["number", "null"] }) returns 0

Actual behavior

Returns null for any nullable type the example seed value is always null instead of a type appropriate placeholder.

Logs, screenshots, and additional context

Fix: normalize schema.type before the switch
const type = Array.isArray(schema.type)
? schema.type.find(t => t !== 'null') ?? 'null'
: schema.type;
Affected: introspection.ts line 108

Acknowledgements

  • I searched existing open and closed issues for this problem.
  • This report does not describe a suspected security vulnerability; I will use the Security Policy for private reporting.
  • I removed secrets, credentials, personal data, and other sensitive information from this report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageAwaiting maintainer review and classification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions