fix(workflow): prevent panic on invalid object schema type during canvas conversion#2652
Open
phpoh wants to merge 1 commit intocoze-dev:mainfrom
Open
fix(workflow): prevent panic on invalid object schema type during canvas conversion#2652phpoh wants to merge 1 commit intocoze-dev:mainfrom
phpoh wants to merge 1 commit intocoze-dev:mainfrom
Conversation
…vas conversion This fix addresses issue coze-dev#2622 where workflow panics when object schema is a map instead of expected []any slice during canvas type conversion. Changes: - Replace direct type assertions `v.Schema.([]any)` with safe type checks - Add proper error messages when schema type is invalid - Add comprehensive unit tests to verify the fix The affected functions: - CanvasVariableToTypeInfo - CanvasBlockInputToTypeInfo - BlockInputToNamedTypeInfo - VariableToNamedTypeInfo Before this fix, invalid schema types caused panic. After this fix, they return clear error messages instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #2622 where workflow panics when object schema is a
map[string]anyinstead of the expected[]anyslice during canvas type conversion.Problem
The code in
type_convert.gouses direct type assertions likev.Schema.([]any)in multiple places. When the schema is not a slice (e.g., a map), this causes a panic instead of returning a proper error.Solution
Replace all direct type assertions with safe type checks using the comma-ok idiom:
Affected Functions
CanvasVariableToTypeInfoCanvasBlockInputToTypeInfoBlockInputToNamedTypeInfoVariableToNamedTypeInfoTesting
Added comprehensive unit tests covering:
[]anyschema (should succeed)map[string]anyschema (should return error, not panic)nilschema (should succeed)All tests pass.
Test plan
go test ./domain/workflow/internal/canvas/convert/... -vgo build ./domain/workflow/...🤖 Generated with Claude Code