Skip to content

Workflow panic when object schema is map during canvas type conversion #2622

@biaoma-ty

Description

@biaoma-ty

Describe the bug

Workflow test run may panic when object schema in canvas is encoded as map[string]interface{} instead of []interface{}.

Current panic:

Workflow execution failure: panic error: interface conversion: interface {} is map[string]interface {}, not []interface {}
.../backend/domain/workflow/internal/canvas/convert/type_convert.go:137

To Reproduce

Steps to reproduce the behavior:

  1. Create or open a workflow containing LLM/object-related inputs/outputs.
  2. Ensure one object schema is stored in map form (e.g. { "fieldA": {...}, "fieldB": {...} }) instead of array form.
  3. Click test run (/api/workflow_api/test_run).
  4. Backend panics during canvas schema conversion.

Expected behavior

Workflow execution should not panic. Canvas conversion should accept both object-schema representations (array and map) and return normal validation errors when input is invalid.

Screenshots

N/A (stack trace included above).

Version:

  • branch: main (local reproduction)
  • reproducible on current code before fix

Environment:

  • go version go1.24.4 darwin/arm64
  • GOOS=darwin
  • GOARCH=arm64
  • GOMOD=/Users/.../coze-studio/backend/go.mod

Additional context

Root cause is hard type assertion in type_convert.go assuming object schema is always []any. In practice, schema may come from map form after marshal/unmarshal or editor flow.

Proposed fix:

  • normalize object schema to a common []any representation in conversion helpers
  • support wrapped object schema ({"type":"object","schema":...})
  • add tests for map-form schema and object-ref parsing
  • avoid extra panic risk on filename metadata type assertion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions