shadow1ng/fscan · error

webscan_program_create_failed

webscan_program_create_failed

Error message

webscan_program_create_failed: %w

What it means

After a successful compile, EvaluateCached builds a runnable program via env.Program(ast, opts...); failure is wrapped as webscan_program_create_failed. This happens when program options (custom functions, optimizations, libraries) conflict with the AST or each other.

Source

Thrown at webscan/lib/Eval.go:174

	var program cel.Program

	if cache != nil {
		if cached, ok := cache[expression]; ok {
			program = cached
		}
	}

	if program == nil {
		ast, issues := env.Compile(expression)
		if issues.Err() != nil {
			return nil, fmt.Errorf("%s: %w", i18n.GetText("webscan_expression_compile_failed"), issues.Err())
		}

		var err error
		program, err = env.Program(ast, GetBaseProgramOptions()...)
		if err != nil {
			return nil, fmt.Errorf("%s: %w", i18n.GetText("webscan_program_create_failed"), err)
		}

		if cache != nil {
			cache[expression] = program
		}
	}

	result, _, err := program.Eval(params)
	if err != nil {
		return nil, fmt.Errorf("%s: %w", i18n.GetText("webscan_expression_eval_failed"), err)
	}

	return result, nil
}

// URLTypeToString 将 TargetURL 结构体转换为字符串
func URLTypeToString(u *UrlType) string {
	var builder strings.Builder

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Inspect the wrapped err for which program option failed
  2. Check GetBaseProgramOptions for duplicate/conflicting function bindings
  3. Ensure every function declared in the env has a matching implementation in options
  4. Upgrade/downgrade the cel-go dependency to a compatible version

Example fix

// before (function declared but not bound)
options := []cel.ProgramOption{cel.Functions(...)} // missing cel.CustomTypeProvider etc.
// after (bind the declared function)
options := []cel.ProgramOption{
    cel.Functions(&cel.FunctionOp{Name: "contains", ...}),
}
Defensive patterns

Strategy: try-catch

Validate before calling

ast, issues := env.Compile(expr)
if issues.Err() != nil { return issues.Err() }
// option conflicts surface at Program(); smoke-test in CI
if _, err := env.Program(ast, GetBaseProgramOptions()...); err != nil { return err }

Try / catch

result, err := Evaluate(expr, params)
if err != nil {
    if strings.Contains(err.Error(), i18n.GetText("webscan_program_create_failed")) {
        log.Printf("program options mismatch for %q: %v", expr, err)
    }
    return err
}

Prevention

When it happens

Trigger: Evaluate/EvaluateCached where GetBaseProgramOptions() returns options incompatible with the compiled AST — e.g. a custom function implementation missing, duplicate option registration, or an option failing validation for this expression.

Common situations: Registering the same custom function/library twice in options, a custom function declared in the env but not bound in program options, CEL library version upgrade changing option behavior (deprecated APIs).

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06). Data as JSON: /api/errors/05e07917df8eeacb. Report an issue: GitHub.