nektos/act · error
Invalid JSON: %v
Error message
Invalid JSON: %v
What it means
Thrown by hashFiles() when one of its arguments is not a string. Every pattern argument must be a string literal or string-valued expression; arrays, booleans, or null are rejected before matching.
Source
Thrown at pkg/exprparser/functions.go:177
json, err := json.MarshalIndent(value.Interface(), "", " ")
if err != nil {
return "", fmt.Errorf("Cannot convert value to JSON. Cause: %v", err)
}
return string(json), nil
}
func (impl *interperterImpl) fromJSON(value reflect.Value) (interface{}, error) {
if value.Kind() != reflect.String {
return nil, fmt.Errorf("Cannot parse non-string type %v as JSON", value.Kind())
}
var data interface{}
err := json.Unmarshal([]byte(value.String()), &data)
if err != nil {
return nil, fmt.Errorf("Invalid JSON: %v", err)
}
return data, nil
}
func (impl *interperterImpl) hashFiles(paths ...reflect.Value) (string, error) {
var ps []gitignore.Pattern
const cwdPrefix = "." + string(filepath.Separator)
const excludeCwdPrefix = "!" + cwdPrefix
for _, path := range paths {
if path.Kind() == reflect.String {
cleanPath := path.String()
if strings.HasPrefix(cleanPath, cwdPrefix) {
cleanPath = cleanPath[len(cwdPrefix):]
} else if strings.HasPrefix(cleanPath, excludeCwdPrefix) {
cleanPath = "!" + cleanPath[len(excludeCwdPrefix):]
}View on GitHub (pinned to 4f41128141)
Solutions
- Pass each pattern as a separate string argument.
- If patterns come as a JSON array, spread it first: hashFiles(fromJSON(patterns)[0], ...).
- Ensure the referenced input/variable is a string type.
- Use toJSON(...) to debug what the argument actually is.
Example fix
# before
${{ hashFiles(inputs.patternList) }}
# after
${{ hashFiles('**/*.go', '**/go.sum') }} Defensive patterns
Strategy: type-guard
Type guard
func allStringArgs(args []reflect.Value) bool {
for _, a := range args {
if a.Kind() != reflect.String { return false }
}
return true
} Prevention
- Pass hashFiles only string literal patterns
- Spread JSON arrays into individual string args
- Debug argument types with toJSON before use
When it happens
Trigger: hashFiles(inputs.patterns) where the input is an array/object; hashFiles(fromJSON('"a"') && true) style coercion mistakes; hashFiles() on a matrix value of non-string type.
Common situations: Trying to pass a list of patterns stored as JSON array directly; untyped inputs defaulting to non-string; copying patterns from a variable that is null.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Cannot parse non-string type %v as JSON
- The following format string is invalid: '%s'
- The following format string references more arguments than w
- Unclosed brackets. The following format string is invalid: '
- Closing bracket without opening one. The following format st
AI-assisted analysis of nektos/act@4f41128141 (2026-08-15).
Data as JSON: /api/errors/941e886167703015.
Report an issue: GitHub.