Skip to content

Activity list created_at end date filtering is inconsistent based on whether start date is provided #38437

@iansltx

Description

@iansltx

Fleet version: <= 4.80 (released)


💥  Actual behavior

Per this code and this discussion, we have nuances in activities API filtering that behave differently than the docs for that endpoint.

Specifically, if you don't provide activity date filters at all, we don't filter the database query by date, but if you provide start and not end the database query adds now as the end date on the filter. Right now we don't future-date activities to my knowledge so this is a distinction without a difference, but the explicit "now" filter does give us unnecessary differing behavior based on a different query parameter than one would expect.

🛠️ To fix

One of the following:

  1. Always filter activities to created_at <= now by default, with an override only when end_created_at is set.
  2. Only filter activities to created_at <= ? if end_created_at is set (because no activities in the table we're looking at will be future-dated anyway).

🧑‍💻  Steps to reproduce

  1. Manually insert an activity into the activities table with a created_at date in the future
  2. Call the List activities endpoint with no parameters. You will see the above activity.
  3. Call the List activities endpoint with only start_created_at set (to a time in the past). You will not see the above activity.

🕯️ More info

Inconsistency discovered during review of #38115.

Metadata

Metadata

Assignees

No one assigned

    Labels

    #g-orchestrationOrchestration product group:productProduct Design department (shows up on 🦢 Drafting board)bugSomething isn't working as documented~backendBackend-related issue.~released bugThis bug was found in a stable release.

    Type

    No type

    Projects

    Status

    📨 Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions