Skip to content

workflow billing: Tempo query uses a 'project' parameter the v4 API rejects (400) #118

Closed

Description

@f3rdy

workflow billing fails for every profile, because it is the first caller of a Tempo query parameter that the Tempo v4 API does not have.

Symptom

$ budjira workflow billing --profile <profile> --month 2026-08
Error: Tempo API error: 400 Client Error: Bad Request for url:
https://api.tempo.io/4/worklogs?limit=1000&offset=0&from=2026-08-01&to=2026-08-31&project=<KEY>

Reproducible on 1.27.0 and 1.27.1 with any profile that has a [profiles.billing] block.

Cause

TempoClient.get_worklogs translates project_key into a project query parameter:

# budjira/tempo/client.py:224
if project_key:
    params["project"] = project_key

workflow billing is the first code path that passes project_key
(budjira/services/workflow.py, the paging loop over profile.project_mappings).
budjira tempo worklogs never passes it, which is why the parameter has been
dormant and untested until the billing command shipped.

Measured against the Tempo v4 API

Same token, same date range, three request shapes:

Request Result
GET /4/worklogs?from=…&to=…&limit=5&project=<KEY> 400 Bad Request
GET /4/worklogs/project/<KEY>?from=…&to=…&limit=5 404 Not Found
GET /4/worklogs?from=…&to=…&limit=5 200 OK, results returned

So the parameter is not merely misnamed — Tempo v4 has no project filter on
this endpoint under either spelling I could find.

Possible fixes

  1. Drop the server-side filter and filter client-side. Fetch the period's
    worklogs without a project parameter and keep only those whose issue belongs
    to the profile's booking projects. The billing command already resolves issue
    keys afterwards, so the mapping is available. Costs one unnecessary fetch of
    other projects' worklogs on a shared Tempo instance.
  2. Filter by issue id. Resolve the booking project's issues first and pass
    issueId, which the endpoint does support. More requests, exact result.
  3. If Tempo does offer a project filter under a different name or endpoint,
    that would be preferable to both — I could not find one, but I only probed
    the two shapes above.

Whichever way: the project_key parameter of get_worklogs currently cannot
work and should either be corrected or removed, so the next caller does not
rediscover this.

Note

1.27.1 fixed something unrelated (register search as a top-level command), so
the report above applies to the current release.

Activity

  1. f3rdy commented on Aug 29, 2026

    @f3rdy
    ContributorAuthor

    Fixed in v1.27.2.

    Went with option 1 + removal, as suggested: TempoClient.get_worklogs no longer accepts project_key (the parameter could never work — removed so no next caller rediscovers it), and the billing report applies the booking project scope client-side: worklogs are filtered by issue key prefix against the profile's booking projects. The issue-key backfill for worklogs Tempo returns without a key is folded into a cached per-issue lookup.

    Regression coverage: a client test asserts the project parameter is never sent, and a service test proves foreign-project worklogs from a shared Tempo instance never enter the report.

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