Skip to content

Mark public ObjectMessage.id and .timestamp as optional#2230

Merged
lawrence-forooghian merged 1 commit into
mainfrom
2026-05-22-objectmessage-public-type-nullability
May 26, 2026
Merged

Mark public ObjectMessage.id and .timestamp as optional#2230
lawrence-forooghian merged 1 commit into
mainfrom
2026-05-22-objectmessage-public-type-nullability

Conversation

@lawrence-forooghian
Copy link
Copy Markdown
Collaborator

@lawrence-forooghian lawrence-forooghian commented May 22, 2026

These declared types are incorrect since these values are not populated for ObjectMessages created by apply-on-ACK.

This is a breaking change to the type declarations, but I think it's the right thing to do given that the declarations do not match the runtime behaviour. You could argue that we could try and fix the runtime behaviour; i.e backfill timestamp based on the server time or something, but I'm not sure it'd be easy to backfill id. Thoughts welcome.

Noticed this whilst working on the spec for the path-based API in ably/specification#427; see PAOM2a/d there. I've incorporated the API change from the current commit into those points.

Summary by CodeRabbit

  • Refactor
    • Object messages no longer require an id or timestamp — these fields may be omitted. This makes message handling more tolerant of missing identifiers or time values.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 186a0337-806d-4c54-b217-cdc34d1bc823

📥 Commits

Reviewing files that changed from the base of the PR and between 02ac44b and 7552659.

📒 Files selected for processing (2)
  • liveobjects.d.ts
  • src/plugins/liveobjects/objectmessage.ts

Walkthrough

ObjectMessage type marks id and timestamp as optional, and the toUserFacingMessage() method no longer uses non-null assertions for id, clientId, connectionId, and timestamp, allowing them to be undefined.

Changes

ObjectMessage field optionality

Layer / File(s) Summary
ObjectMessage interface optionality
liveobjects.d.ts
ObjectMessage.id and ObjectMessage.timestamp fields transition from required to optional types.
Optionality implementation update
src/plugins/liveobjects/objectmessage.ts
toUserFacingMessage() removes non-null assertions (!) from id, clientId, connectionId, and timestamp fields to align with the optional interface contract.

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 I nudged two fields to gently roam,
No bangs to force them from their home,
If missing, they'll softly be unknown,
Lightweight change — a hop, then home 🥕

🚥 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 accurately summarizes the main change: making ObjectMessage.id and .timestamp optional in the public type declarations.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-05-22-objectmessage-public-type-nullability

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 and usage tips.

@github-actions github-actions Bot temporarily deployed to staging/pull/2230/bundle-report May 22, 2026 18:09 Inactive
@github-actions github-actions Bot temporarily deployed to staging/pull/2230/typedoc May 22, 2026 18:10 Inactive
@lawrence-forooghian lawrence-forooghian marked this pull request as ready for review May 22, 2026 18:30
These declared types are incorrect since these values are not populated
for ObjectMessages created by apply-on-ACK.

This is a breaking change to the type declarations, but I think it's the
right thing to do given that the declarations do not match the runtime
behaviour. You could argue that we could try and fix the runtime
behaviour; i.e backfill `timestamp` based on the server time or
something, but I'm not sure it'd be easy to backfill `id`. Thoughts
welcome.

Noticed this whilst working on the spec for the path-based API in [1];
see PAOM2a/d there. I've incorporated the API change from the current
commit into those points.

[1] ably/specification#427

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lawrence-forooghian lawrence-forooghian force-pushed the 2026-05-22-objectmessage-public-type-nullability branch from 02ac44b to 7552659 Compare May 26, 2026 14:22
@lawrence-forooghian lawrence-forooghian merged commit d8f9720 into main May 26, 2026
11 of 14 checks passed
@lawrence-forooghian lawrence-forooghian deleted the 2026-05-22-objectmessage-public-type-nullability branch May 26, 2026 14:25
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.

2 participants