Skip to content

docs(errors): document RejectionStanza and ServerError's response field - #499

Merged
jlucaso1 merged 3 commits into
mainfrom
claude/nifty-bohr-h8udms
Aug 8, 2026
Merged

jlucaso1 merged 3 commits into
mainfrom
claude/nifty-bohr-h8udms

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Documents oxidezap/whatsapp-rust#1257, which changed IqError::ServerError to carry the rejection stanza verbatim instead of discarding it after extracting four summary fields.

  • IqError::ServerError gains response: RejectionStanza — the type="error" <iq> stanza the receive path already decoded, handed over the same way a type="result" response is. Matching with .. is unaffected; constructing the variant by hand now needs the stanza.
  • New public type RejectionStanza, wrapping Arc<OwnedNodeRef> with as_arc()/into_arc(), Deref<Target = OwnedNodeRef>, and a Debug that prints only the tag (<iq>) to avoid leaking attribute/child values — such as a JID — into {e:?} logging on the connect path.
  • From<wacore::request::IqError> for IqError is replaced by IqError::from_response(err, &response), since a bare From has no response to attach.

Changes

  • api/errors.mdx:
    • New "As of PR #1257" intro paragraph.
    • New ### RejectionStanza type-definition section (placed next to ### ServerRejection, which it complements).
    • IqError base-type code block updated with the new response: RejectionStanza field, plus an "Added in PR #1257" note.
    • New "From PR #1257: ServerError carries the rejection stanza" section in the migration guide, covering both the field addition and the Fromfrom_response replacement.

No other page referenced the ServerError field list or the removed From impl, so no other files needed changes. Changelog entries are intentionally left untouched.


Generated by Claude Code


Summary by cubic

Docs update to explain the new response: RejectionStanza on IqError::ServerError and the move to IqError::from_response. Also fixes the fixture snippet by fully qualifying wacore_binary::builder::NodeBuilder.

  • Migration
    • Matches using .. are unchanged.
    • Exhaustive matches now need .. or bind response (E0027).
    • When constructing IqError::ServerError, include response: RejectionStanza (Arc<OwnedNodeRef> via .into()).
    • Replace From<wacore::request::IqError> with IqError::from_response(err, &response).
    • Fixture snippet: use wacore_binary::builder::NodeBuilder, and run unpack() before OwnedNodeRef::new.

Written for commit bfa6d8e. Summary will update on new commits.

Summary by CodeRabbit

  • Documentation
    • Documented improved IQ server error handling.
    • Server errors now retain the complete rejected response for inspection and troubleshooting.
    • Added safe access to the retained response through the public API.
    • Updated error construction guidance to use the response-aware conversion method.
    • Existing manual server-error construction must now include the rejected response.

…ield

Reflects oxidezap/whatsapp-rust#1257: IqError::ServerError gains a
response: RejectionStanza field carrying the rejection stanza verbatim,
and From<wacore::request::IqError> is replaced by IqError::from_response.
@mintlify

mintlify Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
whatsapp-rust 🟢 Ready View Preview Aug 8, 2026, 12:18 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The API documentation records that IqError::ServerError preserves the complete rejected IQ stanza. It documents RejectionStanza, updated construction requirements, and migration from direct conversion to IqError::from_response.

Changes

IQ error API

Layer / File(s) Summary
Error contract and migration
api/errors.mdx
Documents RejectionStanza, adds it to IqError::ServerError, describes accessors and debug behavior, and replaces direct wacore conversion guidance with IqError::from_response.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit preserves each stanza with care,
In RejectionStanza, safely stored there.
ServerError gains response in its nest,
from_response guides the migration quest.
Hop, hop—the API docs now rest.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the documentation changes for RejectionStanza and the ServerError response field.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown

Greptile Summary

The PR updates the typed-error reference for upstream PR #1257.

  • Documents the new RejectionStanza wrapper and its safe Debug behavior.
  • Adds response: RejectionStanza to the documented IqError::ServerError shape.
  • Explains exhaustive-match, manual-construction, fixture-decoding, and from_response migration requirements.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
api/errors.mdx Documents the retained rejection stanza and associated migration guidance; no eligible follow-up defect was established.

Reviews (3): Last reviewed commit: "docs(errors): fully qualify NodeBuilder ..." | Re-trigger Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 8, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/errors.mdx`:
- Line 14: Rewrite the migration guidance in api/errors.mdx at lines 14, 154,
173-175, 615, and 744-777 using concise active-voice, second-person sentences
with one idea per sentence: state directly what you receive in
IqError::ServerError; separately describe storage, parsed fields, and
allocation; separately explain node access, logging, and privacy; address
callers who match or construct ServerError; and separate matching compatibility,
fixture construction, and conversion migration steps.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 576613ed-cc6e-43d1-93a5-ce38ac946f02

📥 Commits

Reviewing files that changed from the base of the PR and between 7e01c0d and 130d945.

📒 Files selected for processing (1)
  • api/errors.mdx

Comment thread api/errors.mdx

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 130d945a86

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/errors.mdx Outdated

Added in PR #1100: `wacore::request::IqError` gained public `is_timeout()` (`true` only for `Timeout`) and `is_transport_unavailable()` (`true` for `NotConnected`, `Disconnected`, and `InternalChannelClosed`) methods, each an exhaustive match so a future variant has to be classified rather than silently defaulting to `false`. `whatsapp_rust::request::IqError` (the crate-level type shown above, with the extra `Socket`/`EncryptSend`/`ClientState`/`EncodeError`/`ParseError` variants) makes the same judgement internally but does not expose it publicly — go through [`ErrorChainExt`](#error-chain-recovery) instead, which handles both types.

Added in PR #1257: `ServerError` carries `response: RejectionStanza` — see [`RejectionStanza`](#rejectionstanza) above and the [migration note](#from-pr-1257-servererror-carries-the-rejection-stanza) below. Matching with `..` is unaffected by this field; only hand-constructing the variant (mainly test fixtures) needs updating.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Cover field-exhaustive ServerError patterns

Downstream matches that explicitly bind all four former fields without .. also need updating: adding response makes those patterns fail with E0027. Saying only hand-constructed variants need changes omits this migration case; advise callers to add .. or bind the new response field.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, fixed in 3084018. Added a note (and before/after example) that a ServerError { code, text, error_type, backoff } match without .. now fails E0027 once response is added — not just hand-constructed variants.


Generated by Claude Code

Comment thread api/errors.mdx Outdated
}
```

A fixture with no real wire response can build one directly: decode a hand-built `<iq type="error">` through `OwnedNodeRef::new`, wrap it in `Arc`, and convert.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Show the required unpack step for fixture stanzas

OwnedNodeRef::new consumes unpacked node bytes, whereas every marshal* function used to encode a hand-built Node includes a leading format byte. A fixture that follows this instruction by marshalling its <iq> and passing that buffer directly to new therefore supplies the wrong input; document the required unpack step or provide a complete construction example.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Correct, and confirmed against advanced/binary-protocol.mdx's existing docs for unpack/marshal. Fixed in 3084018: the fixture snippet now marshals the node, then runs it through wacore_binary::util::unpack to strip the format byte before handing the result to OwnedNodeRef::new, with a link to the format-byte section for context.


Generated by Claude Code

Comment thread api/errors.mdx
}
```

`ServerRejection`'s four fields cover what WA Web's own `parseIqResponse` reads off an error; `RejectionStanza` is the escape hatch for everything that parser (and this crate's) leaves unread — further `<iq>`/`<error>` attributes, `<error>` children such as XMPP application-condition elements, and the raw bytes, which are the only faithful material for logging or replaying a rejection. `Deref<Target = OwnedNodeRef>` (see [`OwnedNodeRef`](/advanced/binary-protocol#ownednoderef-yoke-zero-copy)) keeps every node accessor reachable directly on the wrapper — `response.tag()`, `response.attrs()`, `response.get_optional_child(...)`, or `response.get()` for the underlying `NodeRef`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Split the RejectionStanza explanation into focused sentences

This paragraph combines parser behavior, preserved data categories, logging and replay implications, dereference mechanics, and accessor examples into two dense sentences. Split these independent ideas into concise sentences so the new reference follows the project's one-idea-per-sentence requirement.

AGENTS.md reference: AGENTS.md:L24-L25

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Same style question CodeRabbit raised on this PR (line 14) — skipping for the same reason: the surrounding unchanged content on this page is consistently dense, third-person, rationale-heavy prose (e.g. the http_status() bullet above, or the ServerRejection line), and I matched that established voice deliberately rather than switching tone only for the new sections. CodeRabbit agreed and withdrew its equivalent finding. Happy to revisit if a maintainer wants the whole page's voice changed.


Generated by Claude Code

…unpack step

- Note that a ServerError match binding all four former fields without `..`
  now fails E0027 once `response` is added, not just hand-constructed variants.
- Show the required unpack() step when building a fixture from marshal()
  output for OwnedNodeRef::new, which expects the format byte already stripped.
@greptile-apps
greptile-apps Bot dismissed their stale review August 8, 2026 12:27

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 8, 2026

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread api/errors.mdx Outdated
Matches the fully-qualified style already used for marshal/unpack in the
same snippet, per cubic's review — the bare NodeBuilder reference wasn't
importable as written.
@greptile-apps
greptile-apps Bot dismissed their stale review August 8, 2026 12:33

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@cubic-dev-ai cubic-dev-ai Bot 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.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Documentation-only update to api/errors.mdx explaining an API change from another PR; no behavior, security, or operational tradeoffs are introduced.

Re-trigger cubic

@jlucaso1
jlucaso1 merged commit 05e1d22 into main Aug 8, 2026
4 checks passed
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.

1 participant