Skip to content

Null message fields included in wire JSON instead of omitted (RSL1e, RTL6i3) #2199

@paddybyers

Description

@paddybyers

Spec points

  • RSL1e: "If any of the values are null, then key is not sent to Ably."
  • RTL6i3: Same requirement — a payload with null `data` should be sent as `{ "name": "click" }`, omitting the `data` key entirely.

Observed behaviour

When `data` is `null`/`undefined`, ably-js includes it as `"data": null` in the JSON wire format instead of omitting the key. Same for `name`.

Message serialization in `src/common/lib/types/message.ts` does not strip null/undefined values before `JSON.stringify`.

Failing tests (2)

Test Expected Actual
`RSL1e - null name omitted from body` Body has no `name` key Body has `"name": null`
`RSL1e - null data omitted from body` Body has no `data` key Body has `"data": null`

Reproduction

```bash
RUN_DEVIATIONS=1 npx mocha --grep "RSL1e - null" test/uts/rest/channel/publish.test.ts
```

From PR #2191, branch `uts-rest`.

┆Issue is synchronized with this Jira Task by Unito

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. It's clear that this does need to be fixed.uts-issueIssues raised there there is an apparent discrepancy between this library and the UTS tests

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions