nektos/act · error

Closing bracket without opening one. The following format st

Error message

Closing bracket without opening one. The following format string is invalid: '%s'

What it means

Thrown by format() when a '}' is encountered with no preceding unescaped '{' (state bracketClose at end of input). A lone closing brace cannot be part of a placeholder and was not escaped.

Source

Thrown at pkg/exprparser/functions.go:133

			switch character {
			case '}':
				output += "}"
				replacementIndex = ""
				state = passThrough

			default:
				panic("Invalid format parser state")
			}
		}
	}

	if state != passThrough {
		switch state {
		case bracketOpen:
			return "", fmt.Errorf("Unclosed brackets. The following format string is invalid: '%s'", input)

		case bracketClose:
			return "", fmt.Errorf("Closing bracket without opening one. The following format string is invalid: '%s'", input)
		}
	}

	return output, nil
}

func (impl *interperterImpl) join(array reflect.Value, sep reflect.Value) (string, error) {
	separator := impl.coerceToString(sep).String()
	switch array.Kind() {
	case reflect.Slice:
		var items []string
		for i := 0; i < array.Len(); i++ {
			items = append(items, impl.coerceToString(array.Index(i).Elem()).String())
		}

		return strings.Join(items, separator), nil
	default:
		return strings.Join([]string{impl.coerceToString(array).String()}, separator), nil

View on GitHub (pinned to 4f41128141)

Solutions

  1. Escape the literal closing brace as '}}'.
  2. Balance every placeholder's { and }.
  3. Move regex/code text out of the format string into the arguments.

Example fix

# before
${{ format('json = {0}}', j) }}
# after
${{ format('json = {0}', j) }}
Defensive patterns

Strategy: validation

Validate before calling

// same balancedBraces check as for unclosed brackets: a negative depth
// detects a closing brace with no opener
func noStrayCloseBrace(tpl string) bool { return balancedBraces(tpl) }

Prevention

When it happens

Trigger: format('Hello 0}') or format('}') — closing brace without opening; escaping opening brace but not closing one ('{{' followed by single '}').

Common situations: Asymmetric brace escaping in templates; writing regular expressions or code snippets inside format() arguments.

Related errors


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