Skip to content

ably: fix broken log format when presence history data fails to decode - #714

Open
RaphaelFakhri wants to merge 1 commit into
ably:mainfrom
RaphaelFakhri:fix/presence-decode-log-format
Open

RaphaelFakhri wants to merge 1 commit into
ably:mainfrom
RaphaelFakhri:fix/presence-decode-log-format

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Sep 29, 2026 •

Copy link
Copy Markdown

Description

When RESTChannel.Presence.History receives a presence message whose data can't be decoded (for example, an unknown encoding), the SDK logs the failure with %w. The logger formats messages with fmt.Sprintf, which doesn't support %w, so the log line ends with %!w(*errors.errorString=&{unknown encoding nonsense}) instead of the error text.

This change uses %v, which matches the equivalent messages in rest_channel.go.

Testing

Adds TestRESTPresence_HistoryLogsDecodeFailure. It serves a presence history page with an unknown encoding from a local HTTP server, records the log output through WithLogHandler, and asserts that the decode failure is logged without a formatting error and includes the error text.

go test ./ably -run TestRESTPresence_HistoryLogsDecodeFailure -count=1

Without the fix, the test fails with a log line that contains %!w(. With the fix, it passes.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected error formatting in diagnostic logs when presence-history messages contain an unsupported encoding, so the reported issue is displayed cleanly.
  • Tests
    • Added coverage to verify the diagnostic output for presence-history decoding failures.

RESTPresence history logged the decode failure with %w, which the logger's
Printf-style formatting renders as %!w(...). Use %v, as the message
decoders in rest_channel.go do.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 892ecb93-622c-4021-86dc-80f43c7b1237

📥 Commits

Reviewing files that changed from the base of the PR and between 26cb171 and 41b41cc.

📒 Files selected for processing (2)
  • ably/rest_presence.go
  • ably/rest_presence_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The presence-message decode-failure log now formats errors with %v instead of %w. A REST presence-history test verifies the log message for an unknown encoding.

Changes

Presence decode log

Layer / File(s) Summary
Decode log formatting and test
ably/rest_presence.go, ably/rest_presence_test.go
The decode-failure log uses %v. A REST history test uses an unknown encoding and checks that the logged message contains the encoding without a formatting error.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 41b41

The change corrects presence-history decode-failure logs, and the added test checks the resulting diagnostic. No material merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing the broken log format for presence-history decode failures.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

A rabbit checks the log at night,
The error prints its value right.
An unknown code appears in view,
The test confirms the message too.
Then off I hop through clover dew.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant