Skip to content

feat(functions)!: rename set_auth_token to auth_token - #90

Merged
spydon merged 1 commit into
mainfrom
refactor/functions-auth-token-capability
Nov 4, 2026
Merged

spydon merged 1 commit into
mainfrom
refactor/functions-auth-token-capability

Conversation

@spydon

@spydon spydon commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Renames functions.invocation.set_auth_token to functions.invocation.auth_token and respecifies it in terms of observable behaviour instead of a mutator method.

The old entry read: "Update the authorization token sent with all subsequent function invocations." That describes an implementation shape, not a capability, and it is the shape two SDKs have deliberately removed.

  • supabase/supabase-swift#1233 replaced FunctionsClient.setAuth(token:) with an accessToken closure resolved fresh on every request, which let FunctionsClient drop its lock and become a struct.
  • supabase/supabase-flutter#1739 removed FunctionsClient.setAccessToken() along with the Postgrest and Storage equivalents, since AuthHttpClient already resolves the session token per request.

Both did it for the same reason: despite the name, a setter like this pins a token rather than keeping one in sync. The pinned token outlives the session that was current when it was set, shadowing it across refreshes and sign-outs, and nothing ever clears it. Both SDKs still declare the old ID as implemented, with a note or symbols explaining that there is no setter, which shows the old wording no longer fits what they ship.

The new entry asks what a caller can observe: which token an invocation sends, and which source wins when more than one applies. A stateful setter still satisfies it. It is no longer the only thing that does.

What changed

capabilities/functions.yaml: the rename, plus a description covering the three ways a token reaches an invocation: fixed at construction, resolved per request from an access token provider, or overridden on a single call.

specs/functions/invocation/auth_token.md (new): the resolution order as a numbered precedence. A top-level client's provider returns the session token, or the project API key when there is no token. Header names compare case-insensitively, so a per-call authorization header overrides the provider just like Authorization does. Two notes cover the failure modes actually found in review on the PRs above:

  • A per-call override has to beat a live session token. An auth layer that unconditionally overwrites Authorization breaks this while still looking like it implements the capability. That was a real bug in supabase-swift, found in review on #1233 and fixed there.
  • Why a stateful setter is a shadowing hazard, so the next SDK reaching for one has the reasoning rather than just the permission.

capabilities/client.yaml and specs/client/authentication_integration/cross_client_token_sync.md: no ID change. cross_client_token_sync had the same defect: it specified listening for auth state change events and pushing the JWT to every sub-client as the mechanism. supabase-py (lazily recreates sub-clients on next access) and supabase-csharp (shared GetAuthHeaders callback) already do it differently, and per-request resolution in Swift and Flutter is a third way. Both the description and the spec are reworded around the guarantee, with the mechanism explicitly left open and Realtime called out as the case where pushing is required.

What is deliberately not changed

realtime.client.set_auth_token keeps its name. Realtime is the one case where a setter is the right primitive: it holds a live socket and has to push a new token over it rather than attach one per request, which is why the top-level client genuinely calls it on auth state changes. The naming asymmetry that leaves is a real signal rather than an inconsistency, and the new spec says so.

This breaks six repos on merge

There is no alias or deprecation mechanism for feature IDs, and validateCompliance treats an unrecognised ID as a hard error, not a warning. Every SDK compliance file still naming the old ID fails validation the moment this lands.

The reverse direction is harmless: a missing ID is informational only, treated as not_implemented, so nothing breaks in the window between a repo updating and this merging. Only the stale key is fatal, so the follow-up PRs, one per repo and each a key rename, should merge first:

Repo Line Current value
supabase-js sdk-compliance.yaml:1179 implemented, symbol FunctionsClient.setAuth
supabase-flutter sdk-compliance.yaml:3027 implemented, symbols FunctionsClient.FunctionsClient, FunctionsClient.invoke, with a note that there is no setter
supabase-py sdk-compliance.yaml:614 implemented, symbols {Async,Sync}FunctionsClient.set_auth
supabase-swift sdk-compliance.yaml:1288 implemented, symbol FunctionsClient.Configuration.accessToken
supabase-csharp sdk-compliance.yaml:447 implemented, symbol Client.SetAuth
supabase-kt sdk-compliance.yaml:364 implemented (bare)

supabase-go is unaffected; its compliance file never declared the ID.

Test plan

  • bun run validate: capability matrix valid
  • bun test: 222 passing, 16 files
  • bun run typecheck: clean
  • bun run format-and-lint: clean

@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9e42a1ad-14f5-44c8-828c-1f0dc02bcbf6
Commits

Reviewing files that changed from the base of the PR and between 4ecbf17 and 8b160f3.

Files selected for processing: 4
  • packages/capability-matrix/capabilities/client.yaml
  • packages/capability-matrix/capabilities/functions.yaml
  • packages/capability-matrix/specs/client/authentication_integration/cross_client_token_sync.md
  • packages/capability-matrix/specs/functions/invocation/auth_token.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

The capability was specified as a mutator: "Update the authorization
token sent with all subsequent function invocations." That prescribes a
shape rather than a behaviour, and the shape it prescribes is the one two
SDKs have now removed.

supabase-swift replaced FunctionsClient.setAuth(token:) with an access
token closure resolved per request, and supabase-flutter is removing
FunctionsClient.setAccessToken() for the same reason: a pinned token
outlives the session that was current when it was set, shadowing that
session across refreshes and sign-outs with nothing to clear it.
supabase-csharp never had a setter at all and sits at
partially_implemented purely because of the wording.

Renamed to functions.invocation.auth_token, described in terms of what a
caller can observe: which token an invocation sends, and which source
wins. A stateful setter still satisfies it; it is no longer the only
thing that does.

Realtime's set_auth_token keeps its name. It genuinely is a mutator,
since it holds a live socket and pushes a new token over it rather than
attaching one per request, and both PRs above deliberately kept it.

cross_client_token_sync had the same problem in its description, which
specified propagation on auth state change events as the mechanism.
supabase-py and supabase-csharp already carry notes explaining that they
do it another way, and per-request resolution now makes a third. Reworded
around the guarantee, leaving the mechanism open.

Refs: supabase/supabase-swift#1233, supabase/supabase-flutter#1739
@spydon
spydon force-pushed the refactor/functions-auth-token-capability branch from c225b13 to 8b160f3 Compare October 29, 2026 18:43
@spydon
spydon marked this pull request as ready for review October 29, 2026 18:44
@spydon
spydon requested a review from a team as a code owner October 29, 2026 18:44
@spydon
spydon merged commit b73f439 into main Nov 4, 2026
11 checks passed
@spydon
spydon deleted the refactor/functions-auth-token-capability branch November 4, 2026 09:04
spydon pushed a commit that referenced this pull request Nov 4, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.0.0](capability-matrix/v1.20.0...capability-matrix/v2.0.0)
(2026-11-04)


### ⚠ BREAKING CHANGES

* **functions:** rename set_auth_token to auth_token
([#90](#90))

### Features

* **functions:** rename set_auth_token to auth_token
([#90](#90))
([b73f439](b73f439))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
spydon added a commit to supabase/supabase-flutter that referenced this pull request Nov 4, 2026
supabase/sdk#90 renamed the `functions.invocation.set_auth_token`
capability to `functions.invocation.auth_token`, which was released in
`capability-matrix/v2.0.0` (supabase/sdk#321). The new entry describes
which token an invocation sends and which source wins, instead of
requiring a setter. Compliance validation rejects unknown feature IDs,
so the old key now fails.

This renames the key in `sdk-compliance.yaml`. It also moves the
`validate-sdk-compliance` and `sync-sdk-compliance` workflow pins to
`capability-matrix/v2.0.0`. The old pins would validate against a
registry that has no `auth_token` ID, and the sync workflow would add
`set_auth_token` back.

Validated locally with `bun run validate-compliance` from supabase/sdk
at `capability-matrix/v2.0.0`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Chores**
* Updated compliance checks to use the latest capability-matrix version.
* Refined the documented Functions invocation token capability,
including that an `Authorization` header can override the token.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
spydon added a commit to supabase/supabase-py that referenced this pull request Nov 4, 2026
supabase/sdk#90 renamed the `functions.invocation.set_auth_token`
capability to `functions.invocation.auth_token`, which was released in
`capability-matrix/v2.0.0` (supabase/sdk#321). The new entry describes
which token an invocation sends and which source wins, instead of
requiring a setter. Compliance validation rejects unknown feature IDs,
so the old key now fails.

This renames the key in `sdk-compliance.yaml`. It also moves the
`validate-sdk-compliance` workflow pin to `capability-matrix/v2.0.0`,
since the old pin validates against a registry that has no `auth_token`
ID.

Validated locally with `bun run validate-compliance` from supabase/sdk
at `capability-matrix/v2.0.0`.
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.

2 participants