Skip to content

fix(api): read the single broadcast private flag like a channel join - #2516

Open
hsusul wants to merge 2 commits into
supabase:mainfrom
hsusul:fix/broadcast-single-private-flag
Open

hsusul wants to merge 2 commits into
supabase:mainfrom
hsusul:fix/broadcast-single-private-flag

Conversation

@hsusul

@hsusul hsusul commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Why

POST /api/broadcast/:topic/events/:event read every private value except the exact string true as false. So ?private=True, which Python's requests sends for True, published the message on the public topic with a 202. Subscribers of the private channel never got it, and the RLS write check never ran. This reads private the way a channel join reads config.private.

What changed

  • private is parsed with FlexibleBoolean, so true and false are accepted in any case.
  • Any other value, such as private=1, answers 422 with private must be true or false.
  • The OpenAPI description of private says so.

Scope

  • Covers the private query parameter of the single broadcast endpoint.
  • Leaves persist as is. persist=True already answers 422.
  • Leaves the batch endpoint as is. It reads private from the JSON body with Ecto's :boolean cast, which already rejects "True".

Blast Radius

A request with a non-boolean private, including an empty private=, now gets 422 instead of a public broadcast. Those callers were not getting what they asked for. Requests that send true, false or no private behave as before.

Verification

  • Two new tests in broadcast_single_controller_test.exs: private=True from a caller without a write policy answers 403 and nothing reaches the public topic, and private=1 answers 422. On the test commit without the fix both fail, and the trace shows the public branch of SingleBroadcast.broadcast/7 (single_broadcast.ex:97). With the fix the file passes 41 of 41.
  • On the commit without the fix, the same request with GenCounter stubbed answers 202 and the public subscriber receives the message.
  • broadcast_request_outcome_test.exs, single_broadcast_test.exs, broadcast_controller_test.exs and request_metrics_test.exs pass 109 of 109. mix format --check-formatted passes and mix credo --strict reports nothing new on the changed files. Runs used Elixir 1.20.4 and OTP 29 against local PostgreSQL 17, not CI's Elixir 1.19.5 and OTP 28.

Fixes #2513

POST /api/broadcast/:topic/events/:event treated any private value other
than the exact string "true" as false, so private=True, which Python's
requests sends for True, published the message on the public topic.

Parse private with FlexibleBoolean, the type the channel join uses for
config.private, and answer 422 for any other value.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single broadcast API sends private=True messages to the public topic

1 participant