usememos/memos · error

timestamp() expects one argument

Error message

timestamp() expects one argument

What it means

evaluateTimestamp folds timestamp("RFC3339") and timestamp(<epoch int>) into Unix seconds so filters can compare against created_ts/updated_ts. The helper first requires exactly one argument; any other count is rejected before the value is inspected.

Source

Thrown at internal/filter/parser.go:593

			return left / right, true, nil
		case "_%_":
			if right == 0 {
				return 0, false, errors.New("modulo by zero")
			}
			return left % right, true, nil
		default:
			return 0, false, errors.Errorf("unsupported arithmetic operator %q", call.Function)
		}
	default:
		return 0, false, nil
	}
}

// evaluateTimestamp folds timestamp("RFC3339") and timestamp(<epoch int>) into
// Unix epoch seconds.
func evaluateTimestamp(call *exprv1.Expr_Call) (int64, bool, error) {
	if len(call.Args) != 1 {
		return 0, false, errors.New("timestamp() expects one argument")
	}
	value, err := getConstValue(call.Args[0])
	if err != nil {
		return 0, false, errors.Wrap(err, "timestamp() only supports literal arguments")
	}
	switch v := value.(type) {
	case string:
		ts, err := time.Parse(time.RFC3339, v)
		if err != nil {
			return 0, false, errors.Wrap(err, "invalid timestamp literal")
		}
		return ts.Unix(), true, nil
	case int64:
		return v, true, nil
	default:
		return 0, false, errors.New("timestamp() argument must be an RFC3339 string or epoch int")
	}
}

View on GitHub (pinned to 14d757ce1f)

Solutions

  1. Pass exactly one RFC3339 string or epoch integer: timestamp("2024-01-01T00:00:00Z")
  2. Encode timezone offsets inside the RFC3339 string (+02:00) instead of extra args
  3. For epoch times, pass the raw integer: timestamp(1704067200)

Example fix

// before
created_ts > timestamp("2024-01-01T00:00:00Z", "UTC")

// after
created_ts > timestamp("2024-01-01T00:00:00Z")
Defensive patterns

Strategy: validation

Validate before calling

// TS: build a valid timestamp() call
const iso = new Date(cfg.since).toISOString(); // RFC3339 by construction
if (Number.isNaN(Date.parse(iso))) throw new Error('invalid date');
const filter = `created_ts > timestamp("${iso}")`;

Type guard

const isRfc3339 = (s: string): boolean => !Number.isNaN(Date.parse(s)) && /T\d\d:\d\d:\d\d/.test(s);

Prevention

When it happens

Trigger: Filters like created_ts > timestamp() or created_ts > timestamp("2024-01-01T00:00:00Z", "UTC") — zero or multiple arguments to timestamp().

Common situations: Adding a timezone second argument by analogy with other date libraries; template placeholders that expand to nothing when unset.

Related errors


AI-assisted analysis of usememos/memos@14d757ce1f (2026-08-15). Data as JSON: /api/errors/a1070e0f32bdfeb8. Report an issue: GitHub.