pocketbase/pocketbase · error

@now: %w

Error message

@now: %w

What it means

Thrown by the `@now` filter macro in tools/search/identifier_macros.go when `types.ParseDateTime` fails on the current UTC time. Macros like `@now` are expanded when a filter string (e.g. `created <= @now`) is resolved by the search filter builder. Because the input always comes from `time.Now().UTC()`, this error is defensive and effectively unreachable unless the datetime parser regresses or is changed.

Source

Thrown at tools/search/identifier_macros.go:21

import (
	"fmt"
	"time"

	"github.com/pocketbase/pocketbase/tools/types"
)

// note: used primarily for the tests
var timeNow = func() time.Time {
	return time.Now()
}

var identifierMacros = map[string]func() (any, error){
	"@now": func() (any, error) {
		today := timeNow().UTC()

		d, err := types.ParseDateTime(today)
		if err != nil {
			return "", fmt.Errorf("@now: %w", err)
		}

		return d.String(), nil
	},
	"@yesterday": func() (any, error) {
		yesterday := timeNow().UTC().AddDate(0, 0, -1)

		d, err := types.ParseDateTime(yesterday)
		if err != nil {
			return "", fmt.Errorf("@yesterday: %w", err)
		}

		return d.String(), nil
	},
	"@tomorrow": func() (any, error) {
		tomorrow := timeNow().UTC().AddDate(0, 0, 1)

		d, err := types.ParseDateTime(tomorrow)

View on GitHub (pinned to 5d217ddb50)

Solutions

  1. Confirm you are on a stock, up-to-date PocketBase release (the macro path is time-based, not user-input based)
  2. Replace `@now` with an explicit datetime literal (e.g. `2026-01-01 00:00:00.000Z`) to bypass the macro
  3. If it reproduces on stock code, report it as a regression in types.ParseDateTime with the exact timestamp

Example fix

// before
filter := "created <= @now"
// after
filter := "created <= '2026-08-15 00:00:00.000Z'"
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

// when resolving a filter containing macros
result, err := search.FilterData("created <= @now", resolver)
if err != nil {
    if strings.Contains(err.Error(), "@now:") {
        // macro expansion failed; fall back to explicit literal
        result, err = search.FilterData("created <= '"+time.Now().UTC().Format("2006-01-02 15:04:05.000Z")+"'", resolver)
    }
    if err != nil { return err }
}

Prevention

When it happens

Trigger: Resolving a collection/API filter containing the `@now` identifier (e.g. `filter=created<=%40now`) AND `types.ParseDateTime` failing on a well-formed `time.Time` value.

Common situations: Custom forks or version upgrades that change `types.ParseDateTime` accepted formats; essentially never fires on stock PocketBase builds.

Related errors


AI-assisted analysis of pocketbase/pocketbase@5d217ddb50 (2026-08-15). Data as JSON: /api/errors/c319a7beaa35e075. Report an issue: GitHub.