Skip to content

[WPB-28132] Fix openapi3 docs for oauth scopes. - #5457

Open
fisx wants to merge 5 commits into
developfrom
WPB-28132-fix-openapi3-docs-for-oauth-scopes
Open

[WPB-28132] Fix openapi3 docs for oauth scopes.#5457
fisx wants to merge 5 commits into
developfrom
WPB-28132-fix-openapi3-docs-for-oauth-scopes

Conversation

@fisx

@fisx fisx commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

https://wearezeta.atlassian.net/browse/WPB-28132

This PR fixes two places where the swagger mention of an oauth scope accepted by nginz was forgotten.

It also adds a unit test. In the future, if anybody changes the latest (dev) version in a way that an oauth scope is either:

  • documented, but not enforced,
  • enforced, but not documented, or
  • enforced, but not part of data OAuthScope,

you get a failing test case pointing you to the problem:

    every nginz oauth_scope names a real scope:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             FAIL (0.01s)
      Error message: charts/nginz/values.yaml: 'oauth_scope: thisscopedoesntevenexistwhatsgoingon' matches no scope in Wire.API.OAuth.OAuthScope at any tier, so no OAuth token can ever satisfy it and every endpoint under that location is closed to OAuth.
      Either fix the name, or add the scope.

      CallStack (from HasCallStack):
        assertFailure, called at test/unit/Test/Wire/API/Routes/OAuthScopes.hs:298:7 in wire-api-0.1.0-inplace-wire-api-tests:Test.Wire.API.Routes.OAuthScopes
      Use -p '/every nginz oauth_scope names a real scope/' to rerun this test only.
    enforced scopes and documented scopes agree:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            FAIL (0.20s)
      Error message: OAuth scope declarations are out of sync.

      Columns: version, method, path, accepted by nginz, documented in swagger.
      '-' means no scope. A finding means those last two disagree:

        enforced but not documented  charts/nginz/values.yaml requires a scope the
                                     swagger docs do not mention -- most likely a
                                     missing DescriptionOAuthScope in the routing
                                     table, e.g. on a newly added version of an
                                     endpoint that already had one.
        documented but not enforced  the swagger docs promise a scope nginz does not
                                     require -- a stale annotation, or a missing
                                     oauth_scope: in charts/nginz/values.yaml.

        deviations:
          v17	GET	/self	-	read:self
          v17	GET	/teams/notifications	write:conversations	-
          v17	GET	/teams/{tid}	write:conversations	-
          v17	PUT	/teams/{tid}	write:conversations	-



      CallStack (from HasCallStack):
        assertFailure, called at test/unit/Test/Wire/API/Routes/OAuthScopes.hs:307:30 in wire-api-0.1.0-inplace-wire-api-tests:Test.Wire.API.Routes.OAuthScopes
      Use -p '/enforced scopes and documented scopes agree/' to rerun this test only.

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Aug 18, 2026
@fisx
fisx force-pushed the WPB-28132-fix-openapi3-docs-for-oauth-scopes branch 2 times, most recently from 68a5a30 to 7072686 Compare August 18, 2026 20:02
@fisx
fisx marked this pull request as ready for review August 18, 2026 20:05
@fisx
fisx requested review from a team as code owners August 18, 2026 20:05
@fisx

fisx commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author
wire-api> test/unit/Test/Wire/API/Routes/OAuthScopes.hs:98:27: error: [GHC-87897]
wire-api>     • Exception when trying to run compile-time code:
wire-api>         /nix/var/nix/builds/nix-87-2643120627/wire-api/../../charts/nginz/values.yaml: withBinaryFile: does not exist (No such file or directory)
wire-api>       Code: (embedFile
wire-api>                =<< makeRelativeToProject "../../charts/nginz/values.yaml")
wire-api>     • In the untyped splice:
wire-api>         $(embedFile
wire-api>             =<< makeRelativeToProject "../../charts/nginz/values.yaml")
wire-api>    |
wire-api> 98 |   case Yaml.decodeEither' $(embedFile =<< makeRelativeToProject "../../charts/nginz/values.yaml") of
wire-api>    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Comment thread libs/wire-api/src/Wire/API/Routes/Public/Swagger.hs
Comment thread libs/wire-api/test/unit/Test/Wire/API/Routes/OAuthScopes.hs
@fisx
fisx force-pushed the WPB-28132-fix-openapi3-docs-for-oauth-scopes branch from c05aef0 to e2e0926 Compare August 19, 2026 13:08
@fisx
fisx force-pushed the WPB-28132-fix-openapi3-docs-for-oauth-scopes branch from e2e0926 to 410cfdc Compare August 19, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants