{"record":{"id":"93ea01bc97394b3d","repo":"coleam00/Archon","slug":"native-tool-schema-enum-for-key-must-be-non","errorCode":null,"errorMessage":"native tool schema: enum for '${key}' must be non-empty strings","messagePattern":"native tool schema: enum for '(.+?)' must be non-empty strings","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/providers/src/community/pi/native-tools.ts","lineNumber":34,"sourceCode":"  if (\n    schema.type !== 'object' ||\n    typeof schema.properties !== 'object' ||\n    schema.properties === null\n  ) {\n    throw new Error('native tool inputSchema must be an object schema with `properties`');\n  }\n  const props = schema.properties as Record<string, Record<string, unknown>>;\n  const required = new Set(\n    Array.isArray(schema.required) ? (schema.required as unknown[]).filter(isString) : []\n  );\n\n  const shape: Record<string, TSchema> = {};\n  for (const [key, prop] of Object.entries(props)) {\n    let field: TSchema;\n    if (Array.isArray(prop.enum)) {\n      const values = prop.enum.filter(isString);\n      if (values.length === 0) {\n        throw new Error(`native tool schema: enum for '${key}' must be non-empty strings`);\n      }\n      field = Type.Union(values.map(v => Type.Literal(v)));\n    } else if (prop.type === 'string') {\n      field = Type.String();\n    } else if (prop.type === 'boolean') {\n      field = Type.Boolean();\n    } else {\n      throw new Error(\n        `native tool schema: unsupported type for '${key}' (only string / string-enum / boolean)`\n      );\n    }\n    if (typeof prop.description === 'string') {\n      field = Type.Unsafe<unknown>({ ...field, description: prop.description });\n    }\n    shape[key] = required.has(key) ? field : Type.Optional(field);\n  }\n  return Type.Object(shape);\n}","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/providers/src/community/pi/native-tools.ts#L16-L52","documentation":"When converting an enum property in a tool's inputSchema, jsonSchemaToTypeBox filters the enum values to strings; if nothing survives (the enum is empty or contains no strings) it throws. Only string enums can be represented as TypeBox literal unions for Pi native tools.","triggerScenarios":"inputSchema property with `enum: []`, or `enum: [1, 2, 3]` / `[true]` containing no string values, passed to buildPiNativeToolDefinitions.","commonSituations":"Numeric enums ported from OpenAPI specs, empty placeholder enums, or enums with mixed types where non-string members are silently dropped and an all-non-string enum trips the error.","solutions":["Ensure every enum member is a string: `enum: ['low', 'high']`","Replace a numeric enum with string literals","If values are dynamic, use `type: 'string'` and validate in the tool handler instead of `enum`"],"exampleFix":"// before\n{ type: 'object', properties: { level: { type: 'number', enum: [1, 2] } } }\n// after\n{ type: 'object', properties: { level: { enum: ['low', 'high'] } } }","handlingStrategy":"validation","validationCode":"for (const [key, prop] of Object.entries(schema.properties)) {\n  if (Array.isArray(prop.enum) && prop.enum.filter(v => typeof v === 'string').length === 0) {\n    throw new Error(`property '${key}' has an empty or non-string enum`);\n  }\n}","typeGuard":"function hasValidStringEnum(prop: unknown): prop is { enum: string[] } {\n  return typeof prop === 'object' && prop !== null && Array.isArray((prop as any).enum)\n    && (prop as any).enum.every((v: unknown) => typeof v === 'string') && (prop as any).enum.length > 0;\n}","tryCatchPattern":"try {\n  registerNativeTool(tool);\n} catch (err) {\n  if (err.message.includes(\"enum for '\")) {\n    console.error(`Fix enum values on tool '${tool.name}': all members must be non-empty strings`);\n  }\n  throw err;\n}","preventionTips":["Use only string literal enum members in tool schemas","Never ship an empty enum array; use type:'string' if values are unconstrained","Add a schema lint test that asserts enums are string arrays"],"tags":["schema","enum","validation"],"backgroundTag":"invalid-enum-schema","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}