compile panics on unresolvable adapter config - #290
Merged
Conversation
…string variable In validateSchemaAttrs, cty.Value.AsString() was called on cty.String values without first checking IsKnown()/IsNull(). When a schema-aware adapter config attribute referenced a variable with no default, the resulting unknown cty.String caused a panic. Add an unknown/null guard before the per-type coercion so that: - step-level input (evalCtx == nil) continues to defer the value to runtime; - adapter-level config (evalCtx != nil) emits a located diagnostic naming the field and stating that the value cannot be determined. Add regression tests for both root workflows and subworkflows reached via compileSubworkflows/compileSingleSubworkflow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
brokenbot
approved these changes
Jul 31, 2026
brokenbot
left a comment
Collaborator
There was a problem hiding this comment.
Approving. The fix adds an unknown/null guard in validateSchemaAttrs before the coercion switch that previously called AsString() on unresolved cty.String values, panicking. Adapter-config mode (non-nil evalCtx) now emits a located diagnostic naming the attribute; step-input mode (nil evalCtx) defers to runtime with an empty placeholder, preserving prior behavior. Type-check branch continues before the guard so the type-error path is unaffected. Two regression tests cover the root and subworkflow paths (child diagnostics propagate via compileSubworkflows). Full workflow suite passes; all CI gates green.
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.
compile-panics-on-unresolvable-adapter-config
Repository:
brokenbots/criteriaConfirmed behavior
When the workflow compiler has access to an adapter's
ConfigSchema, an adapterconfigattribute of typestringthat is assigned from a workflow variable with nodefaultproduces a panic instead of a diagnostic.Refs under test and results:
origin/main(0829f887968d42d8b5e4d53685c6f48086390caf) — reproduced.v0.5.5(6ac528757d2615d64b4b5f78949a12bdae1870fa) — reproduced.Observed panic stack trace on both refs (root workflow path):
For subworkflows the same panic propagates through:
Shapes that reproduced the panic on both refs:
variable "missing_default" { type = string }and an adapter withconfig { system_prompt = var.missing_default }; the compiler is given a realConfigSchemafor the adapter. Seeevidence/run-main.mdandevidence/run-stable.md, Shape A2.workflowblocks. Seeevidence/run-main.mdandevidence/run-stable.md, Shape C.Shapes that did not reproduce — already correct, do not regress:
criteria-adapter-copilotbinary, the CLI falls back to schema-unverified decoding viadecodeAttrsToStringMap, which already guards unknown/null values and returns a located diagnostic.defaultcompiles cleanly; the default value is folded into the adapter config.ConfigSchemaand an unresolved variable returns a normal located diagnostic, no panic.input {}referencing an unresolved variable is runtime-deferred and compiles cleanly.Required behavior
workflow.validateSchemaAttrsmust not callcty.Value.AsString()on acty.Stringvalue unless the value is known and non-null.configattribute evaluates to an unknown or nullcty.String, the compiler must emit a located diagnostic error that names the attribute and states that the value cannot be determined.Diagnostics) to the caller instead of panicking.compileSubworkflows/compileSingleSubworkflow.decodeAttrsToStringMap), the known-default path, the step-input path, and the type-error path must continue to behave exactly as they did before the fix.The fix belongs in
workflow/compile_validation.goinsidevalidateSchemaAttrs, before the per-type coercion branch reads a concrete string from the value.Exit criteria
workflow/callsworkflow.Compile(orworkflow.CompileWithContext) with a real adapterConfigSchemaand a workflow containing astringvariable with nodefaultreferenced fromadapter "copilot" "bot" { config { system_prompt = var.missing_default } }. The test must fail before the fix by triggering the panic and pass after the fix by receiving a non-emptyDiagnosticsand no panic.workflow/covers the subworkflow path: a parent workflow invokes a child workflow whose adapter config contains the same unresolvedstringvariable pattern. The test must fail before the fix by triggering the panic and pass after the fix by receiving a non-emptyDiagnosticsand no panic.workflow/continue to pass after the fix.make testpasses at the repository root after the fix.