{"record":{"id":"8f241b934269d4a3","repo":"golang/go","slug":"evaluating-condition-q-w","errorCode":null,"errorMessage":"evaluating condition %q: %w","messagePattern":"evaluating condition %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/script/engine.go","lineNumber":538,"sourceCode":"\t\t\tif impl == nil {\n\t\t\t\treturn false, fmt.Errorf(\"unknown condition prefix %q; known: %v\", prefix, slices.Collect(maps.Keys(e.Conds)))\n\t\t\t}\n\t\t\tif !impl.Usage().Prefix {\n\t\t\t\treturn false, fmt.Errorf(\"condition %q cannot be used with a suffix\", prefix)\n\t\t\t}\n\t\t} else {\n\t\t\timpl = e.Conds[cond.tag]\n\t\t\tif impl == nil {\n\t\t\t\treturn false, fmt.Errorf(\"unknown condition %q\", cond.tag)\n\t\t\t}\n\t\t\tif impl.Usage().Prefix {\n\t\t\t\treturn false, fmt.Errorf(\"condition %q requires a suffix\", cond.tag)\n\t\t\t}\n\t\t}\n\t\tactive, err := impl.Eval(s, suffix)\n\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"evaluating condition %q: %w\", cond.tag, err)\n\t\t}\n\t\tif active != cond.want {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\n\treturn true, nil\n}\n\nfunc (e *Engine) runCommand(s *State, cmd *command, impl Cmd) error {\n\tif impl == nil {\n\t\treturn cmdError(cmd, errors.New(\"unknown command\"))\n\t}\n\n\tasync := impl.Usage().Async\n\tif cmd.background && !async {\n\t\treturn cmdError(cmd, errors.New(\"command cannot be run in background\"))\n\t}","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/script/engine.go#L520-L556","documentation":"Engine.conditionsActive wraps any error returned by a Cond's Eval method with the condition tag (engine.go:537-539). The inner %w error is typically one of the 'unrecognized GOOS/GOARCH/compiler/GOEXPERIMENT' errors, indicating the suffix value is syntactically valid (known prefix) but the value itself is invalid.","triggerScenarios":"Using [GOOS:linnux] — the prefix GOOS is known, so execution reaches the eval closure, which then rejects the unknown value 'linnux' and that error is wrapped here. Same for [compiler:gcc], [GOEXPERIMENT:bogus].","commonSituations":"Correct condition name but misspelled suffix value; experiment renamed across Go versions; using a value valid in one context but not the current build.","solutions":["Read the wrapped inner error to identify which value is unrecognized.","Fix the suffix to a valid value for that condition (see KnownOS/KnownArch/buildcfg experiment list).","If the value was removed in a newer Go version, gate the line behind a version check or remove it."],"exampleFix":"// before\n[GOOS:macos] exec go build   // -> evaluating condition \"GOOS:macos\": unrecognized GOOS \"macos\"\n// after\n[GOOS:darwin] exec go build","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// errors.Is / errors.As on the wrapped chain to distinguish cause.\nif errors.Is(err, something) { ... }\n// The inner error after 'evaluating condition %q:' reveals the rejected value.","preventionTips":["Treat this wrapper as a pointer to the inner 'unrecognized ...' error and fix the suffix value.","Validate suffix values (GOOS/GOARCH/compiler/GOEXPERIMENT) before running the script."],"tags":["go-script-test","conditions","error-wrapping","go-toolchain"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}