Skip to content

fix(daemon): surface the relay's rejection reason on a failed send - #261

Merged
sanil-23 merged 1 commit into
tinyhumansai:mainfrom
sanil-23:fix/daemon-log-send-reason
Jul 15, 2026
Merged

fix(daemon): surface the relay's rejection reason on a failed send#261
sanil-23 merged 1 commit into
tinyhumansai:mainfrom
sanil-23:fix/daemon-log-send-reason

Conversation

@sanil-23

@sanil-23 sanil-23 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

When a daemon reply is rejected by the relay, the log showed only:

send to 7mt2xZ… failed: HTTP 400: /messages

That hides why it was rejected. The relay returns a specific reason in the body — body must be encrypted ciphertext, prekey envelope requires ephemeralKey and signedPreKeyId, ratchet metadata requires ratchetKey and messageNumber, etc. — each pointing at a different, actionable cause. Without it, a 400 is undiagnosable from the daemon log alone.

Fix

TinyPlaceError already carries the parsed { error } response body. Fold that reason into the sendRaw failure log so the line becomes:

send to 7mt2xZ… failed: HTTP 400: /messages — body must be encrypted ciphertext

Log-only change — no protocol or transport behavior is touched, and it deliberately edits the daemon runtime rather than TinyPlaceError.message (which the CLI asserts on exactly).

Validation

  • pnpm --filter @tinyhumansai/tinyplace build
  • pnpm --filter @tinyhumansai/tinyplace test — 579 passed (adds a case asserting the reason is folded into the send-failure log) ✅

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved daemon error logs to include relevant HTTP status and nested error details when message delivery fails.
    • This provides clearer diagnostic information for relay and peer communication failures.
  • Tests

    • Added coverage verifying that detailed send-failure information appears in daemon logs.

A failed reply logged only `send to <peer> failed: HTTP 400: /messages`,
hiding *why* the relay rejected it (e.g. "body must be encrypted ciphertext",
"prekey envelope requires ephemeralKey and signedPreKeyId"). TinyPlaceError
already carries the parsed `{ error }` body — fold it into the log line so the
failure is diagnosable without adding request logging.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@sanil-23 is attempting to deploy a commit to the Vezures Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

DaemonRuntime.sendRaw now appends nested HTTP error details to relay-send failure logs when available. A daemon test verifies formatting for a thrown TinyPlaceError.

Changes

Daemon error logging

Layer / File(s) Summary
Relay send failure reporting
sdk/typescript/src/cli/daemon/runtime.ts, sdk/typescript/tests/daemon.test.ts
sendRaw extracts nested HTTP error details for failure logs, and the daemon test verifies the formatted status and message.

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

Possibly related PRs

Suggested reviewers: senamakel

Poem

I’m a rabbit with logs in my burrow,
Catching errors before they can scurry.
HTTP clues now hop into view,
With tests to confirm every hue.
Send failures speak clearly—cheerfully!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: surfacing the relay rejection reason when a daemon send fails.
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.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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

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

🧹 Nitpick comments (1)
sdk/typescript/src/cli/daemon/runtime.ts (1)

468-474: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a camelCase local for the response body.

body_ at Line 468 violates the repository rule requiring camelCase variable names. Rename it to bodyValue or responseBody.

Proposed rename
-              const body_ = (error as { body?: unknown }).body;
+              const bodyValue = (error as { body?: unknown }).body;
-              return body_ &&
-                typeof body_ === "object" &&
-                "error" in body_ &&
-                (body_ as { error?: unknown }).error !== undefined
-                ? String((body_ as { error: unknown }).error)
+              return bodyValue &&
+                typeof bodyValue === "object" &&
+                "error" in bodyValue &&
+                (bodyValue as { error?: unknown }).error !== undefined
+                ? String((bodyValue as { error: unknown }).error)
🤖 Prompt for 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.

In `@sdk/typescript/src/cli/daemon/runtime.ts` around lines 468 - 474, In the
error-response formatting logic, rename the local variable body_ to a camelCase
name such as bodyValue or responseBody, and update all references within that
expression consistently.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@sdk/typescript/src/cli/daemon/runtime.ts`:
- Around line 468-474: In the error-response formatting logic, rename the local
variable body_ to a camelCase name such as bodyValue or responseBody, and update
all references within that expression consistently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8efb705c-2505-4514-8fe1-20c0f08e2c4d

📥 Commits

Reviewing files that changed from the base of the PR and between 33defda and 02cd346.

📒 Files selected for processing (2)
  • sdk/typescript/src/cli/daemon/runtime.ts
  • sdk/typescript/tests/daemon.test.ts

@sanil-23
sanil-23 merged commit 1a988f2 into tinyhumansai:main Jul 15, 2026
9 of 10 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