glanceapp/glance · error
parsing variable: %v
Error message
parsing variable: %v
What it means
Wraps any lower-level failure from parseConfigVariableOfType while expanding {{...}} variable references in glance.yml. The config loader regex-replaces variable expressions; if resolving a variable (env, secret, file-from-env) returns an error, it is wrapped as 'parsing variable: <cause>' and the whole config parse fails. The message deliberately prefixes context but keeps the inner error (e.g. 'environment variable FOO not found').
Source
Thrown at internal/glance/config.go:171
// in the regex has been changed without updating the below code
return match
}
prefix := string(groups[1])
if prefix == `\` {
if len(match) >= 2 {
return match[1:]
} else {
return nil
}
}
typeAsString, variableName := string(groups[2]), string(groups[3])
variableType := ternary(typeAsString == "", configVarTypeEnv, typeAsString)
parsedValue, returnOriginal, localErr := parseConfigVariableOfType(variableType, variableName)
if localErr != nil {
err = fmt.Errorf("parsing variable: %v", localErr)
return nil
}
if returnOriginal {
return match
}
return []byte(prefix + parsedValue)
})
if err != nil {
return nil, err
}
return replaced, nil
}
// When the bool return value is true, it indicates that the caller should use the original valueView on GitHub (pinned to 91324e8de7)
Solutions
- Read the inner error after 'parsing variable: ' — it names the exact variable and cause (env not found, secret read failure, etc.).
- Export the missing environment variable or fix its name in the {{ env.X }} expression.
- For {{ secret.X }}, ensure /run/secrets/X exists and is readable by the Glance process.
- For {{ file-from-env.X }}, set X and verify the path it points to.
- Note: only expressions whose name matches envVariableNamePattern are resolved; non-matching env names are left as-is, so check the pattern if the value isn't substituted.
Example fix
# before: APP_TOKEN not exported $ glance --config glance.yml # error: parsing variable: environment variable APP_TOKEN not found # after $ export APP_TOKEN=... $ glance --config glance.yml
Defensive patterns
Strategy: try-catch
Validate before calling
# Expand-and-check before starting Glance
for var in $(grep -oE '\{\{ *env\.[A-Za-z_][A-Za-z0-9_]* *\}\}' glance.yml | sed -E 's/.*env\.([A-Za-z0-9_]+).*/\1/'); do
[ -n "${!var}" ] || { echo "missing env var: $var"; exit 1; }
done Try / catch
// Running config programmatically (custom tooling):
err := cfg.Parse()
if err != nil {
if strings.HasPrefix(err.Error(), "parsing variable: ") {
cause := strings.TrimPrefix(err.Error(), "parsing variable: ")
// cause names the variable and stage: env lookup, secret read, file read
log.Fatalf("config variable problem: %s", cause)
}
} Prevention
- Keep a checklist of every {{ env.* }}/{{ secret.* }}/{{ file-from-env.* }} referenced in glance.yml and assert them in deploy scripts.
- Run `glance config:validate` in the target environment, not just locally.
When it happens
Trigger: Any {{ env.FOO }}, {{ secret.foo }}, or {{ file-from-env.FOO }} expression in glance.yml whose resolution fails: missing env var, unreadable /run/secrets file, or file-from-env path problems. The outer regex match groups determine variableType and variableName passed to the resolver.
Common situations: Deploying to an environment missing variables referenced in the config template; Docker secrets not mounted at /run/secrets; typo'd variable names after refactor; renaming env vars without updating glance.yml.
Related errors
- readFileFromEnv: environment variable %s not found
- environment variable %s not found
- reading secret file: %v
- readFileFromEnv: file path %s is not absolute
- readFileFromEnv: reading file from %s: %v
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/567e1fc694fd5f5f.
Report an issue: GitHub.