Skip to content

fix: correctly parse JWT ValidMethods from env by enabling split_words#2334

Merged
cemalkilic merged 1 commit intosupabase:masterfrom
singh-inder:fix/valid-methods-parsing
Feb 19, 2026
Merged

fix: correctly parse JWT ValidMethods from env by enabling split_words#2334
cemalkilic merged 1 commit intosupabase:masterfrom
singh-inder:fix/valid-methods-parsing

Conversation

@singh-inder
Copy link
Contributor

@singh-inder singh-inder commented Jan 16, 2026

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

JWT ValidMethods not parsed from env because split_words was missing on the struct tag, causing envconfig to look for GOTRUE_JWT_VALIDMETHODS instead of GOTRUE_JWT_VALID_METHODS. Since v2.71.1, cli defaults to asymmetric keys, which caused valid HS256 tokens to be rejected.

What is the new behavior?

This change adds split_words to ensure the correct env var is used. I assume that GOTRUE_JWT_VALID_METHODS is the correct env var but if it isn't, then this issue can also be solved by updating the env var passed to auth service in supabase cli to

			env = append(env, "GOTRUE_JWT_VALIDMETHODS=HS256,RS256,ES256")

Additional context

The following screenshots are from print statements I added

  1. config.JWT.ValidMethods was nil because it was looking for wrong env var. It defaulted to jwk key algorithm (ES256).

    if config.JWT.ValidMethods == nil {
    config.JWT.ValidMethods = []string{}
    for _, key := range config.JWT.Keys {
    alg := GetSigningAlg(key.PublicKey)
    config.JWT.ValidMethods = append(config.JWT.ValidMethods, alg.Alg())
    }

    Screenshot 2026-01-17 041756

    Screenshot 2026-01-17 042002
  2. After
    image

@singh-inder singh-inder requested a review from a team as a code owner January 16, 2026 23:38
@singh-inder
Copy link
Contributor Author

@coveralls
Copy link

coveralls commented Jan 19, 2026

Pull Request Test Coverage Report for Build 22099601302

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 69.034%

Totals Coverage Status
Change from base Build 22075658585: 0.0%
Covered Lines: 14941
Relevant Lines: 21643

💛 - Coveralls

@aantti
Copy link

aantti commented Jan 19, 2026

Also supabase/cli#4524 ?

@aantti
Copy link

aantti commented Jan 19, 2026

@hf @kangmingtay

@aantti
Copy link

aantti commented Jan 21, 2026

Possibly also supabase/supabase#42037

@singh-inder
Copy link
Contributor Author

Closing this for now to avoid confusion with env var name. For reference: supabase/cli#4818 (comment)

@singh-inder singh-inder closed this Feb 8, 2026
@singh-inder singh-inder reopened this Feb 16, 2026
@cemalkilic
Copy link
Contributor

Hi @singh-inder, thanks for the contribution! can you please rebase the master? Then we can get this merged

@singh-inder singh-inder force-pushed the fix/valid-methods-parsing branch from 11ab4b6 to 9400a53 Compare February 17, 2026 13:05
@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Improved configuration parsing for JWT-related settings to enhance consistency with environment variable handling.

Walkthrough

The ValidMethods field in the JWTConfiguration struct has been updated with an additional struct tag. The field's tag was changed from json:"-" to json:"-" split_words:"true". This modification adds configuration parsing behavior for handling environment variables with word splitting, while maintaining the existing JSON serialization behavior of excluding this field from JSON marshaling/unmarshaling.

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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

@singh-inder
Copy link
Contributor Author

Hi @cemalkilic, Thanks for the review. I've rebased on master.

@cemalkilic cemalkilic merged commit a6076bc into supabase:master Feb 19, 2026
4 checks passed
@singh-inder singh-inder deleted the fix/valid-methods-parsing branch February 19, 2026 07:50
cstockton pushed a commit that referenced this pull request Feb 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.187.0](v2.186.0...v2.187.0)
(2026-02-23)


### Features

* add metadata field to all hooks
([#2365](#2365))
([c675749](c675749))
* check current password on change
([#2364](#2364))
([33b87ae](33b87ae))
* **indexworker:** add max users threshold for rollout
([#2374](#2374))
([a2066c6](a2066c6))
* **metrics:** added a gauge with version information
([#2375](#2375))
([911ad0b](911ad0b))
* support custom oauth & oidc providers
([#2357](#2357))
([53021f6](53021f6))


### Bug Fixes

* case-insensitive Bearer token scheme matching
([#2387](#2387))
([36d712d](36d712d))
* correctly parse JWT ValidMethods from env by enabling split_words
([#2334](#2334))
([a6076bc](a6076bc))
* flaky index worker test
([#2366](#2366))
([961a7e6](961a7e6))
* **hooks:** propagate error objects from hook calls
([#2380](#2380))
([3ca1e88](3ca1e88))
* session upgrade percentage should be based on session, not request
([#2371](#2371))
([510e68b](510e68b))

---
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants