semaphoreui/semaphore · error

value of field ' ' is not valid: (Must match regex: ' ')

Error message

value of field '%v' is not valid: %v (Must match regex: '%v')

What it means

validate() returns this error when a config struct field tagged with `rule:"<regex>"` does not match that regular expression. The message shows the field name, its (masked) value, and the required regex. It is Semaphore's built-in config validation run at startup/after config changes.

Solutions

  1. Compare the shown value against the regex in the message and correct the value in config/config.env or the UI
  2. Trim whitespace and stray quotes from the value
  3. Check the `rule:` tag on the field in util/config.go for the exact requirement
  4. After an upgrade, review changed rule tags for fields you set

Example fix

// before
EMAIL_SENDER=not-an-email
// after
EMAIL_SENDER=admin@example.com
Defensive patterns

Strategy: validation

Validate before calling

var emailRe = regexp.MustCompile(`^[^@\s]+@[^@\s]+\.[^@\s]+$`)
if v := os.Getenv("EMAIL_SENDER"); v != "" && !emailRe.MatchString(v) {
    return fmt.Errorf("EMAIL_SENDER %q will be rejected: must look like an email", v)
}

Type guard

func matchesRule(value string, rule string) bool {
    ok, _ := regexp.MatchString(rule, value)
    return ok
}

Try / catch

if err := util.ConfigValidate(tmpConfig); err != nil {
    return fmt.Errorf("config invalid, aborting start: %w", err)
}

Prevention

When it happens

Trigger: Setting a config field to a value violating its rule tag, e.g. an email that does not match the required pattern, a bad URL in an endpoint field, or an empty string where a non-empty pattern is required.

Common situations: Email/URL fields with typos; trailing spaces or quotes copied from docs; legacy values that fail newly added rule tags after upgrade; empty values for required fields.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of semaphoreui/semaphore@1774ccb71a (2026-09-07). Data as JSON: /api/errors/e16d7a9d67284f22. Report an issue: GitHub.

Appendix: source

Thrown at util/config.go:1430

		} else if fieldType.Type.Kind() == reflect.Uint {
			strVal = strconv.FormatUint(fieldValue.Uint(), 10)
		} else {
			strVal = fieldValue.String()
		}

		match, _ := regexp.MatchString(rule, strVal)

		if match {
			continue
		}

		fieldName := strings.ToLower(fieldType.Name)

		if strings.Contains(fieldName, "password") || strings.Contains(fieldName, "secret") || strings.Contains(fieldName, "key") {
			strVal = "***"
		}

		return fmt.Errorf(
			"value of field '%v' is not valid: %v (Must match regex: '%v')",
			fieldType.Name, strVal, rule,
		)
	}

	return nil
}

// resolveKeySource returns the key material from a KeySource: the inline Value,
// or the trimmed contents of File. Value and File are mutually exclusive.
func resolveKeySource(ks KeySource, name string) (string, error) {
	if ks.Value != "" && ks.File != "" {
		return "", fmt.Errorf("%s: 'value' and 'file' are mutually exclusive", name)
	}
	if ks.File != "" {
		data, err := os.ReadFile(ks.File)
		if err != nil {
			return "", fmt.Errorf("%s: read key file %q: %w", name, ks.File, err)

View on GitHub (pinned to 1774ccb71a)