Skip to content

TimestampFilter uses wrong format when timezone != GMT #472

Open

Description

@metskem

I am using the following code(snippet) :

dateFilter := client.TimestampFilterList{}
dateFilter.Before(graceDate)

serviceInstanceListOptions := client.ServiceInstanceListOptions{
      ListOptions:          &client.ListOptions{UpdatedAts: dateFilter},
}
serviceInstances, err := cfClient.ServiceInstances.ListAll(ctx, &serviceInstanceListOptions)

This works fine as long as your local timezone is GMT, then RCF3339 formats to something like 'YYYY-MM-DDThh:mm:ssZ', which is the format the CF V3 API expects.
In my case the timezone is Europe/Amsterdam, and then RFC3339 formats to 'YYYY-MM-DDThh:mm:ss+02:00'

The ListAll call returns the error:

error executing GET request for /v3/service_instances?updated_ats%5Blt%5D=2025-05-10T11%3A54%3A11%2B02%3A00: cfclient error (CF-BadQueryParameter|10005): The query parameter is invalid: Updated ats has an invalid timestamp format. Timestamps should be formatted as 'YYYY-MM-DDThh:mm:ssZ'

My guess is this requires some tweaks in the Serializer?

Thanks!

Activity

  1. metskem commented on May 20, 2025

    @metskem
    ContributorAuthor

    BTW, the unescaped URL is

    /v3/service_instances?updated_ats[lt]=2025-05-10T11:54:11+02:00

    Maybe changing

    timestamp.Format(time.RFC3339)

    to

    timestamp.UTC().Format(time.RFC3339)

    would suffice.

  2. sneal commented on May 28, 2025

    @sneal
    Contributor

    You're correct, the API expects all timestamps to be in UTC, no timezone offset.

    I worry that if the client serializer auto-converts the given timestamp to UTC it will not be what the consumer of the client expected. I think it's probably better to get an error so the client consumer knows to pass a UTC timestamp and knows there's a conversion happening. If anything I think I might like to see a clearer error message from the client instead of a query parameter error returned from the API. What do you think?

  3. metskem commented on May 29, 2025

    @metskem
    ContributorAuthor

    Hmm, TBH the results being returned this way would be exactly what I expected.
    The timestamp passed in by the consumer is honored.
    If the consumer would pass a Europe/Amsterdam timestamp of 09:00, or a UTC timestamp of 07:00, he would get the same results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions