Unit tests for idempotency key parsing and request hashing in core
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, typescript
Research direction
Read the key pattern and parseIdempotencyKey at line 9 and lines 70-87 of app/packages/core/src/idempotency.ts, which cover canonical and requestHash. Use app/tests/app/typing-core.test.ts as the model for a pure unit test and safe-writes.test.ts for the expected behaviour. Create app/tests/app/idempotency-core.test.ts with no database or network. Done when every acceptance criterion has an assertion and the Docker command with --network none passes.
Written by the indexing model from the issue text.
Description
A retried command is matched to its first run by requestHash, which hashes a canonical JSON form (object keys sorted, undefined fields dropped). If that canonical form changed, a retry would get a 409 instead of the stored answer. The rules are pure, but they are tested only through HTTP with a database.
Where to look
app/packages/core/src/idempotency.ts(lines 9 and 70–87): the key pattern,parseIdempotencyKey,canonicalandrequestHash.app/tests/app/safe-writes.test.ts: the end-to-end idempotency tests, for context.app/tests/app/typing-core.test.ts: an example of a core unit test.
Acceptance criteria
- A new
app/tests/app/idempotency-core.test.tsneeds no database or network. -
parseIdempotencyKey:undefinedgivesnull; 1 and 255 visible ASCII characters are accepted; an empty string, 256 characters, a space, a non-ASCII character and a non-string are refused withINVALID_IDEMPOTENCY_KEY. -
requestHash: the same object with keys in another order (also nested) hashes the same; a field set toundefinedhashes like a missing field; array order matters;nullandundefinedinput give the same hash. - No production code changes, unless a test finds a real bug (then describe it in the PR).
How to check
docker build --file docker/Dockerfile --target test --tag flux-idem-core app && docker run --rm --network none flux-idem-core node_modules/.bin/tsx --test tests/app/idempotency-core.test.ts, then docker image rm flux-idem-core.
New to Flux? Start with CONTRIBUTING. Comment here to say you are taking it.
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 0
- Avg merge
- 18h 3m
- Merged PRs (30d)
- 254
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ColdPhase/flux
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Live platform rows: Firefox Join fails at ICE on native Linux Docker (child of #63 AC-3)Possibly taken @Zamojski5 claimed this 1 day ago. Open
ColdPhase/flux#496 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
F-027 A10 — Connect AI order and labels in Settings (rest of #410)Possibly taken @Zamojski5 claimed this 2 days ago. Open
ColdPhase/flux#493 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
documentation good first issue hacktoberfest help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
libredb/libredb-studio#1756 ·
Maintainers usually reply within 1 day
-
state:triage-needed
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
lingdojo/kana-dojo#32365 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
friction
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
kentcdodds/kody#3706 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
copperheadhq/copperhead#378 ·
Maintainers usually reply within 1 day