Repository navigation
fix(server): Linear rate limits no longer show as a rejected API key #38001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
StiensWout
wants to merge
11
commits into
pingdotgg:main
Choose a base branch
from
StiensWout:t3/1064-linear-rate-limits-are-shown-as-rejected
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+212
−40
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0db9449
test(server): temporary tracker probe failures fail the connection list
StiensWout 1cb837d
fix(server): Linear rate limits no longer show as a rejected API key
StiensWout dae7b0b
test(server): stub the stored credential with Effect.succeedSome
StiensWout 6b25300
test(server): keep the repro's stored credential stub as written
StiensWout 56b31e7
test(server): allow the repro's Option.some credential stub past the …
StiensWout 213a2d5
docs(server): clarify tracker probe failure tradeoff
StiensWout 8eb50bc
chore: credit the models that worked on this change
StiensWout ec426df
Merge remote-tracking branch 'origin/main' into t3/1064-linear-rate-l…
juliusmarminge 27d466e
test(server): stub the stored credential with Effect.succeedSome
juliusmarminge a774c55
fix(server): keep credential and team controls when the tracker is un…
juliusmarminge 499208d
fix(web,mobile): offer Retry when the issue tracker is unreachable
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| import { describe, expect, it } from "@effect/vitest"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Layer from "effect/Layer"; | ||
| import { IssueTrackerKind, ProjectId } from "@t3tools/contracts"; | ||
| import { IssueTrackerError } from "@t3tools/source-control-core/server/IssueTracker"; | ||
|
|
||
| import * as ServerSecretStore from "../auth/ServerSecretStore.ts"; | ||
| import * as IssueTrackerBindings from "../persistence/IssueTrackerBindings.ts"; | ||
| import * as IssueTrackerConnections from "./IssueTrackerConnections.ts"; | ||
| import * as IssueTrackerRegistry from "./IssueTrackerRegistry.ts"; | ||
|
|
||
| const linear = IssueTrackerKind.make("linear"); | ||
| const projectId = ProjectId.make("project-1"); | ||
|
|
||
| const listWithProbeFailure = (reason: IssueTrackerError["reason"]) => | ||
| Effect.gen(function* () { | ||
| const tracker = { | ||
| kind: linear, | ||
| capabilities: { | ||
| create: true, | ||
| edit: true, | ||
| comment: true, | ||
| labels: true, | ||
| assignees: true, | ||
| reactions: true, | ||
| templates: true, | ||
| linkedPullRequests: true, | ||
| events: true, | ||
| search: true, | ||
| }, | ||
| standalone: { | ||
| tracker: linear, | ||
| displayName: "Linear", | ||
| host: "linear.app", | ||
| scopeNoun: "team", | ||
| credential: { label: "Personal API key", helpUrl: null }, | ||
| }, | ||
| getViewer: () => Effect.succeed("wout"), | ||
| listIssues: () => Effect.succeed({ items: [], nextCursor: null }), | ||
| getIssue: () => Effect.die("unused"), | ||
| getComments: () => Effect.succeed({ comments: [], nextCursor: null }), | ||
| probeCredential: () => | ||
| Effect.fail( | ||
| new IssueTrackerError({ | ||
| tracker: linear, | ||
| operation: "viewer", | ||
| reason, | ||
| detail: | ||
| reason === "rate-limited" | ||
| ? "Linear's rate limit was reached." | ||
| : "Linear could not be reached.", | ||
| }), | ||
| ), | ||
| }; | ||
| return yield* IssueTrackerConnections.IssueTrackerConnections.pipe( | ||
| Effect.flatMap((service) => service.list), | ||
| Effect.result, | ||
| Effect.provide( | ||
| IssueTrackerConnections.layer.pipe( | ||
| Layer.provide( | ||
| Layer.mergeAll( | ||
| Layer.succeed( | ||
| IssueTrackerRegistry.IssueTrackerRegistry, | ||
| IssueTrackerRegistry.fromTrackers([tracker]), | ||
| ), | ||
| Layer.mock(ServerSecretStore.ServerSecretStore)({ | ||
| get: () => Effect.succeedSome(new TextEncoder().encode("saved-valid-key")), | ||
| }), | ||
| Layer.mock(IssueTrackerBindings.IssueTrackerBindingsRepository)({ | ||
| list: Effect.succeed(new Map([[projectId, { tracker: linear, scope: "FAC" }]])), | ||
| }), | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| }); | ||
|
|
||
| describe("IssueTrackerConnections", () => { | ||
| it.effect.each(["rate-limited", "failed"] as const)( | ||
| "lists a %s probe as unavailable, keeping the credential and bound scopes", | ||
| (reason) => | ||
| Effect.gen(function* () { | ||
| const result = yield* listWithProbeFailure(reason); | ||
| expect(result).toMatchObject({ | ||
| _tag: "Success", | ||
| success: { | ||
| trackers: [ | ||
| { | ||
| connected: true, | ||
| account: null, | ||
| unavailable: true, | ||
| scopes: [{ key: "FAC", name: "FAC" }], | ||
| }, | ||
| ], | ||
| bindings: { [projectId]: { tracker: linear, scope: "FAC" } }, | ||
| }, | ||
| }); | ||
| }), | ||
| ); | ||
|
|
||
| it.effect("lists an authentication refusal as a rejected saved credential", () => | ||
| Effect.gen(function* () { | ||
| const result = yield* listWithProbeFailure("unauthenticated"); | ||
| expect(result).toMatchObject({ | ||
| _tag: "Success", | ||
| success: { trackers: [{ connected: true, account: null, unavailable: false, scopes: [] }] }, | ||
| }); | ||
| }), | ||
| ); | ||
| }); |
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.