Skip to content

[task] Document string-to-number coercion in schema descriptions #4312

Description

@github-actions

Objective

Update JSON schema field descriptions to document that numeric fields accept string representations for YAML compatibility.

Context

Related to discussion #4307. The runtime accepts string representations of numbers (e.g., timeout: "300") and automatically converts them using strconv.Atoi(), but the schema only defines "type": "integer". This creates validation gaps where workflows work at runtime but fail external schema validation.

Approach

  1. Update schema descriptions in pkg/parser/schemas/main_workflow_schema.json for affected fields
  2. Add explicit documentation that strings are accepted and converted
  3. Add examples showing both numeric and string formats
  4. Consider adding $comment fields for tooling authors

Affected Fields

  • timeout-minutes: Currently "type": "integer", accepts string
  • max: Currently "type": "integer", accepts string
  • max-turns: Currently "type": "integer", accepts string
  • max-patch-size: Currently "type": "integer", accepts string

Files to Modify

  • Update: pkg/parser/schemas/main_workflow_schema.json (add descriptions to field definitions)

Acceptance Criteria

  • Schema descriptions explicitly mention string-to-number coercion
  • Examples show both formats: timeout: 300 and timeout: "300"
  • $comment fields added explaining conversion rules for tooling authors
  • Documentation clearly states: "Accepts numeric values as strings (e.g., '300') for YAML compatibility"

Implementation Notes

Code Evidence from pkg/workflow/metrics.go:245-257:

func ConvertToInt(val any) int {
    switch v := val.(type) {
    case int:
        return v
    case int64:
        return int(v)
    case float64:
        return int(v)
    case string:  // This behavior needs documentation
        if i, err := strconv.Atoi(v); err == nil {
            return i
        }
    }
    return 0
}

AI generated by Plan Command for discussion #4307

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions