Skip to content

Wrap network failures from baza fetch calls#30

Open
GHX5T-SOL wants to merge 1 commit into
zerocracy:masterfrom
GHX5T-SOL:fix/baza-network-errors
Open

Wrap network failures from baza fetch calls#30
GHX5T-SOL wants to merge 1 commit into
zerocracy:masterfrom
GHX5T-SOL:fix/baza-network-errors

Conversation

@GHX5T-SOL

Copy link
Copy Markdown

Summary

  • wrap rejected fetch() calls in baza() with a consistent Error
  • preserve the original failure on the thrown error's cause
  • add a focused regression test for network-level fetch failures

Fixes #28.

Validation

  • npx jest --config jest.config.ts --no-color --ci test/baza.test.ts -t 'wraps network failures' --coverage=false
  • npx eslint . --config eslint.config.mjs
  • npx tsc --target es2020 --module nodenext --outDir dist index.ts src/baza.ts src/prompts.ts src/resources.ts src/server.ts src/to_gpt.ts src/tools.ts
  • git diff --check HEAD~1 HEAD
  • git show --format= --patch HEAD | gitleaks stdin --no-banner --redact

Notes

  • Full npx jest --config jest.config.ts --no-color --ci currently fails in the existing live baza and server tests because the fixture token receives HTTP error responses from the Zerocracy API; the focused network-failure regression passes.
  • AI-assisted contribution disclosure: I used OpenAI Codex to inspect the issue, make this focused code/test change, and run the checks above. I reviewed the resulting diff before submission.

@0crat

0crat commented May 16, 2026

Copy link
Copy Markdown

@GHX5T-SOL Hi! Your branch name "fix/baza-network-errors" doesn't follow our naming convention, so I've deducted -6 points as per our policy. Please use the ticket number as the branch name - in this case, "29" would be perfect. Your current score is -6, and you can check your Zerocracy account for updates.

@GHX5T-SOL

Copy link
Copy Markdown
Author

Thanks for flagging this. I missed the branch-name convention on this PR; I will use the ticket number as the branch name for future Zerocracy contributions.

@kreinba kreinba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The try/catch wraps the rejected fetch in a thrown Error with the original kept on cause, the new test asserts the message and cause for a TypeError thrown from fetch, jest and eslint pass locally. Addresses #28 without touching unrelated code. 0 inline comments.

@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