temporalio/temporal · error

invalid value for %s: %s

Error message

invalid value for %s: %s

What it means

The SearchPrecision value must be exactly one of the constants Day, Hour, Minute, or Second. Any other string (wrong case, plural, empty) fails the switch in convertComparisonExpr and returns this error.

Source

Thrown at common/archiver/s3store/query_parser.go:185

		parsedQuery.startTime = &timestamp
	case SearchPrecision:
		val, err := sqlquery.ExtractStringValue(valStr)
		if err != nil {
			return err
		}
		if op != "=" {
			return fmt.Errorf("only operation = is support for %s", SearchPrecision)
		}
		if parsedQuery.searchPrecision != nil && *parsedQuery.searchPrecision != val {
			return fmt.Errorf("only one expression is allowed for %s", SearchPrecision)
		}
		switch val {
		case PrecisionDay:
		case PrecisionHour:
		case PrecisionMinute:
		case PrecisionSecond:
		default:
			return fmt.Errorf("invalid value for %s: %s", SearchPrecision, val)
		}
		parsedQuery.searchPrecision = new(val)

	default:
		return fmt.Errorf("unknown filter name: %s", colNameStr)
	}

	return nil
}

View on GitHub (pinned to bde624efd1)

Solutions

  1. Use the exact capitalized constants: Day, Hour, Minute, Second
  2. Normalize/validate user input to one of the four constants before building the query
  3. Reference the exported constants (s3store.PrecisionDay etc.) instead of string literals in Go code

Example fix

// before
`SearchPrecision = "day"`
// after
`SearchPrecision = "Day"` // or fmt.Sprintf("SearchPrecision = %q", s3store.PrecisionDay)
Defensive patterns

Strategy: validation

Validate before calling

var validPrecisions = map[string]bool{"Day": true, "Hour": true, "Minute": true, "Second": true}
func validatePrecision(q string) error {
    for _, p := range []string{"Day", "Hour", "Minute", "Second"} {
        if strings.Contains(q, "SearchPrecision = \""+p+"\"") { return nil }
    }
    return fmt.Errorf("SearchPrecision must be Day, Hour, Minute, or Second")
}

Type guard

func isValidPrecision(s string) bool {
    switch s {
    case "Day", "Hour", "Minute", "Second":
        return true
    }
    return false
}

Try / catch

parsed, err := parser.Parse(q)
if err != nil {
    if strings.Contains(err.Error(), "invalid value for SearchPrecision") {
        return nil, fmt.Errorf("use one of Day, Hour, Minute, Second (case-sensitive): %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Parsing `SearchPrecision = "day"` (lowercase), `SearchPrecision = "Daily"`, or any misspelled precision value.

Common situations: Case-sensitivity mistakes; UI passing user-friendly labels like 'per hour'; localization or capitalization drift between services composing the query.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/5c86d69b322107c3. Report an issue: GitHub.