cloudfoundry / cloudfoundry/go-cfclient

TimestampFilter uses wrong format when timezone != GMT

Open
#472 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
70
Forks
134
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in client/filter.go around the Serializer referenced by the issue and reproduce the TimestampFilter behavior with a non-GMT timezone such as Europe/Amsterdam. Confirm that the generated service-instances query uses the CF V3 API's expected YYYY-MM-DDThh:mm:ssZ timestamp format.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.