Skip to content

Wrap baza network failures#31

Open
AjTheSpidey wants to merge 3 commits into
zerocracy:masterfrom
AjTheSpidey:codex/wrap-baza-network-errors
Open

Wrap baza network failures#31
AjTheSpidey wants to merge 3 commits into
zerocracy:masterfrom
AjTheSpidey:codex/wrap-baza-network-errors

Conversation

@AjTheSpidey

Copy link
Copy Markdown

Fixes #28.

baza() now wraps network-level fetch() failures in a regular Error with the request method and URL in the message. It still keeps the original failure attached as cause, so callers get a readable error without losing the lower-level reason.

I added a mocked fetch test for the network-failure path.

Tested:

  • npx jest --config jest.config.ts --no-color --ci -t "wraps network failures" --coverage=false
  • npx eslint . --config eslint.config.mjs
  • npx tsc --target es2020 --module nodenext --outDir dist index.ts src/*.ts equivalent via PowerShell file list

I did not claim the full Jest suite as passing locally. The existing live baza tests hit Zerocracy with the placeholder token and currently fail on the server response before this change is involved.

@GHX5T-SOL GHX5T-SOL left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed and verified.

The patch wraps only fetch() rejections in baza(), keeps the existing HTTP status handling unchanged, and preserves the original failure on cause. The regression stubs globalThis.fetch to reject and asserts the wrapped message plus cause, so it covers the issue without relying on live Zerocracy responses.

Validation I ran locally on head eb40343:

  • npm ci -> completed; npm reported existing audit findings, and this PR does not change dependencies.
  • npm exec jest -- --config jest.config.ts --no-color --ci test/baza.test.ts -t 'wraps network failures' --coverage=false -> 1 passed, 4 skipped.
  • npm exec eslint -- src/baza.ts test/baza.test.ts --config eslint.config.mjs -> passed.
  • npm exec tsc -- --noEmit -> passed.
  • git diff --check origin/master...HEAD -> passed.
  • git diff origin/master...HEAD | gitleaks stdin --no-banner --redact --exit-code 1 -> no leaks found.

Limitation: running all of test/baza.test.ts locally is red on the live endpoint cases with the placeholder token (HTTP error 303/400 responses), so I used the mocked regression for this PR-specific path.

@0crat

0crat commented May 26, 2026

Copy link
Copy Markdown

@AjTheSpidey Hi! Just a quick note about branch naming: according to our guidelines, it's best to name branches using the ticket number you're working on. For your branch "codex/wrap-baza-network-errors", a simpler name like "30" would be perfect! This earned you -6 points, bringing your current score to -6. You can track your progress on your Zerocracy account 📊

@0crat

0crat commented May 26, 2026

Copy link
Copy Markdown

@GHX5T-SOL Hey! Nice work on the review! 🎯 You've earned +10 points for this one: +18 as a basis, but -8 since no comments were posted (our policy encourages reviewers to share feedback to help improve code quality). Your running score is +188 - keep it up! Don't forget to check your Zerocracy account too.

@yegor256

Copy link
Copy Markdown
Member

Please fix the merge conflicts so this pull request can be merged.

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.

Network errors in baza.ts fetch call are not handled, leading to TypeError instead of the expected Error

4 participants