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

  1. Pass each pattern as a separate string argument.
  2. If patterns come as a JSON array, spread it first: hashFiles(fromJSON(patterns)[0], ...).
  3. Ensure the referenced input/variable is a string type.
  4. 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

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

Related errors


AI-assisted analysis of nektos/act@4f41128141 (2026-08-15). Data as JSON: /api/errors/941e886167703015. Report an issue: GitHub.