Skip to content

Re-add support for `X-Request-ID #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2025
Merged

Conversation

goncalossilva
Copy link
Member

Per our internal discussion on the usefulness of X-Request-ID for traceability. The generator function is configurable via the request_id_fn API constructor argument, defaulting to a random UUID v4 per request when unspecified.


A note about optionally providing request_id_fn as a constructor parameter: I considered adding a request_id parameter to each API function similar to our TypeScript SDK, but decided against it due to significant argument pollution for all methods, and that it has no practical use for most users*. If ourselves or a user ever needs to customize this, that can be done ergonomically by using TodoistApi (or TodoistAsyncApi) as a context manager or passing a context-aware request_id_fn function.

*TypeScript SDK claims it is used for idempotency, but that's incorrect… besides logging, our API just ignores this /cc @pedroalves0, let's tweak or clean up those comments?


A note about removing tests/test_api_async.py: I hadn't yet come across this test file, but I found it pretty useless. It's validating how TodoistAPIAsync invokes the TodoistAPI constructor correctly, but that's an implementation detail. All test files and functions that test actual behavior do it across both TodoistAPI and TodoistAPIAsync. That's actually valuable, unlike testing constructor internals.

Have it configurable via `request_id_fn` API constructor argument,
defaulting to a random UUID v4 per request when unspecified.
@goncalossilva goncalossilva requested a review from chiara-doist May 1, 2025 02:45
@goncalossilva goncalossilva requested a review from a team as a code owner May 1, 2025 02:45
@goncalossilva
Copy link
Member Author

goncalossilva commented May 1, 2025

@chiara-doist I don't expect an in-depth review if you aren't able to dedicate the time. Scrutinizing my rationale above and reviewing just the high-level shape of the PR would be enough. 😊 Thank you!

@pedroalves0
Copy link
Member

*TypeScript SDK claims it is used for idempotency, but that's incorrect… besides logging, our API just ignores this /cc @pedroalves0, let's tweak or clean up those comments?

Done in Doist/todoist-api-typescript#295.

Copy link

@chiara-doist chiara-doist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a look, all in all, implementation looks good and the thought process is sound (thanks for a thorough description)!

I left 2 comments: non-blocking, pre-approving the PR!

@goncalossilva goncalossilva merged commit 3a20d8f into main May 7, 2025
5 checks passed
@goncalossilva goncalossilva deleted the goncalossilva/x-request-id branch May 7, 2025 17:18
@goncalossilva
Copy link
Member Author

Thank you @chiara-doist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants