Repository navigation
fix(runs): authenticate 'tw runs star' and 'tw runs unstar' - #696
Merged
cristianrcv merged 1 commit intoOct 5, 2026
Merged
Conversation
Both commands failed with "Unauthorized" against a live Platform, even though the caller's token was valid and the same request made by hand succeeded. The workflow star endpoints are missing their security requirement in the Platform OpenAPI spec, so the generated SDK passes no auth names for them. ApiClient.invokeAPI skips authentication entirely when the auth name array is null, rather than falling back to the configured scheme, so the request went out with no Authorization header at all. Default the auth names to BearerAuth when an operation declares none. This routes through the SDK's own authentication, reusing the token already set with setBearerToken. In SDK 1.200.0 eleven operations declare no security: the three *WorkflowStar ones, six GA4GH ones, ServiceInfoApi.info and NextflowApi.nextflowVersions. The last two are genuinely public and the GA4GH ones target the same host, so sending the token is harmless; a token is always present by the time the client is built. The existing star tests matched on method and path only, so an unauthenticated request satisfied them. Assert the Authorization header instead. The mock server is shared across the test class without a reset, so the verification allows for the star requests other tests record. This is a workaround, not the cure: the spec is still missing the security block in SDK 1.230.0. Once that is fixed the override becomes a no-op. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tw runs starandtw runs unstar, added in #685, fail withUnauthorizedagainst a live Platform. This stacks on that PR and fixes them.Stack:
master→ #685 (API 1.101) → this PR. Base isfeat/NOTASK-api-1.101-catch-up; review #685 first.The bug
Found while testing #685 against
cloud.stage-seqera.io(API 1.231.0):The same call by hand returns
200, so it is not a permissions problem.tw -vshows the star request going out without anAuthorizationheader, while every other request in the same invocation has one:Root cause
The workflow star endpoints are missing their
securityrequirement in the Platform OpenAPI spec, so the generated SDK passesnullauth names:authNamesargument toinvokeAPIWorkflowsApi.describeWorkflownew String[]{"BearerAuth"}WorkflowsApi.createWorkflowStarnullWorkflowsApi.deleteWorkflowStarnullApiClient.invokeAPIthen skips authentication entirely when that array is null — it guards theupdateParamsForAuthcall with a null check rather than falling back to the configured scheme. So the request is sent unauthenticated.Scanning all 263
*WithHttpInfomethods in SDK 1.200.0, eleven declare no security: the three*WorkflowStarones, six GA4GH ones,ServiceInfoApi.infoandNextflowApi.nextflowVersions.Fix
Default the auth names to
BearerAuthwhen an operation declares none, in theApiClientsubclassAbstractApiCmdalready builds. This goes through the SDK's own authentication path, reusing the token fromsetBearerToken.The fix is general rather than special-casing the two star calls, so a future spec gap cannot silently send another request unauthenticated. The other nine affected operations are unaffected in practice:
infoandnextflowVersionsare genuinely public, and the GA4GH ones target the same host the token belongs to. A token is always present by the time the client is built —AbstractApiCmdthrowsMissingTowerAccessTokenExceptionotherwise.Why CI did not catch it
The star tests matched on method and path only, so an unauthenticated request satisfied them — which is why #685 is green at 819/819. This PR asserts the
Authorizationheader instead.Note the test class shares one MockServer without a reset, so star requests from sibling tests are recorded too; the verification allows for those rather than pinning an exact count.
Verification
./gradlew test: 821 tests, 0 failures (819 + the 2 new).checkLicensespasses.isStarred: truethenfalseafterunstar.info,organizations list,workspaces list,pipelines list,compute-envs list,organizations quotas,teams list,access-tokens list— the override touches every API call, andtw infoin particular uses one of the previously unauthenticated endpoints.Note for reviewers
This is a workaround, not the cure. The spec is still missing the
securityblock in SDK 1.230.0, which the last PR in the stack bumps to — I checked, and all three star methods still passnull. The real fix belongs intower-sdk-gencode; this override is harmless to keep afterwards and becomes a no-op.🤖 Generated with Claude Code