Skip to content

chore!: remove api.ts unnecessary calls#22168

Merged
jakehwll merged 3 commits into
mainfrom
jakehwll/react-query-enabled-cleanup
Apr 22, 2026
Merged

chore!: remove api.ts unnecessary calls#22168
jakehwll merged 3 commits into
mainfrom
jakehwll/react-query-enabled-cleanup

Conversation

@jakehwll
Copy link
Copy Markdown
Contributor

@jakehwll jakehwll commented Feb 18, 2026

Warning

The change of the status code from 404 to 204 could break peoples code downstream. Adding this as a breaking change incase.

Theres a whole ton of noise around failed requests, these are all unrelated to the actual thing that is broken at hand (and are confusing).

  • Change /api/v2/organizations/.../templates/.../versions/.../previous to return 204 instead of 404 (actually makes more sense because the content doesn't exist, but the route is found.
  • Remove unnecessary calls to /api/v2/users/me/appearance when the user isn't logged in.
  • Remove unnecessary calls to /api/v2/deployment/stats when the deployment stats aren't allowed to be seen.
  • Various changes to workspace-sharing so we don't make unnecessary calls.

Whats left:

  • /api/v2/users/me still 401s on the login page. This persists as when the user is logged in but tries to reach the sign-in page they should be redirected to the app, not sign in again.
  • monaco-editor is still upset... we theoretically could inject an environment that can serve workers... but eh.

Old

% pnpm playwright:test -g "create workspace with default and required parameters"

> coder-v2@ playwright:test /home/coder/coder/site
> playwright test --config=e2e/playwright.config.ts -g 'create workspace with default and required parameters'

...

Running 2 tests using 1 worker

  ✓  1 …e/setup/addUsersAndLicense.spec.ts:7:5 › setup deployment (8.2s)
     2 ….ts:79:5 › create workspace with default and required parameters
[console][error] Failed to load resource: the server responded with a status of 401 (Unauthorized)
[console][error] Failed to load resource: the server responded with a status of 401 (Unauthorized)
[response] url=http://localhost:3111/api/v2/users/me/appearance status=401 body={"message":"You are signed out or your session has expired. Please sign in again to continue.","detail":"Cookie \"coder_session_token\" or query parameter must be provided."}
[response] url=http://localhost:3111/api/v2/users/me status=401 body={"message":"You are signed out or your session has expired. Please sign in again to continue.","detail":"Cookie \"coder_session_token\" or query parameter must be provided."}
[console][error] Failed to load resource: the server responded with a status of 403 (Forbidden)
[response] url=http://localhost:3111/api/v2/deployment/stats status=403 body={"message":"Forbidden.","detail":"You don't have permission to view this content. If you believe this is a mistake, please contact your administrator or try signing in with different credentials."}
[console][error] Failed to load resource: the server responded with a status of 403 (Forbidden)
[response] url=http://localhost:3111/api/v2/deployment/stats status=403 body={"message":"Forbidden.","detail":"You don't have permission to view this content. If you believe this is a mistake, please contact your administrator or try signing in with different credentials."}
[console][error] Failed to load resource: the server responded with a status of 404 (Not Found)
[response] url=http://localhost:3111/api/v2/organizations//provisionerdaemons status=404 body={"message":"Resource not found or you do not have access to this resource"}
[console][error] Failed to load resource: the server responded with a status of 404 (Not Found)
[response] url=http://localhost:3111/api/v2/organizations/default/templates/a4e8096d/versions/agreeable_glenn33/previous status=404 body={"message":"No previous template version found for \"agreeable_glenn33\"."}
[console][warning] Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq
[console][warning] You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker
[console][error] Failed to load resource: the server responded with a status of 401 (Unauthorized)
[console][error] Failed to load resource: the server responded with a status of 401 (Unauthorized)
[response] url=http://localhost:3111/api/v2/users/me/appearance status=401 body={"message":"You are signed out or your session has expired. Please sign in again to continue.","detail":"Cookie \"coder_session_token\" or query parameter must be provided."}
[response] url=http://localhost:3111/api/v2/users/me status=401 body={"message":"You are signed out or your session has expired. Please sign in again to continue.","detail":"Cookie \"coder_session_token\" or query parameter must be provided."}
[console][error] Failed to load resource: the server responded with a status of 403 (Forbidden)
[response] url=http://localhost:3111/api/v2/deployment/stats status=403 body={"message":"Forbidden.","detail":"You don't have permission to view this content. If you believe this is a mistake, please contact your administrator or try signing in with different credentials."}
  ✓  2 …5 › create workspace with default and required parameters (7.0s)atus of 403 (Forbidden)
[response] url=http://localhost:3111/api/v2/deployment/stats status=403 body={"message":"Forbidden.","detail":"You don't have permission to view this content. If you believe this is a mistake, please contact your administrator or try signing in with different credentials."}
[console][error] Failed to load resource: the server responded with a status of 403 (Forbidden)
[response] url=http://localhost:3111/api/v2/deployment/stats status=403 body={"message":"Forbidden.","detail":"You don't have permission to view this content. If you believe this is a mistake, please contact your administrator or try signing in with different credentials."}

  2 passed (56.1s)

23 LOL (Lines of logs)

New

% pnpm playwright:test -g "create workspace with default and required parameters"

> coder-v2@ playwright:test /home/coder/coder/site
> playwright test --config=e2e/playwright.config.ts -g 'create workspace with default and required parameters'

...

Running 2 tests using 1 worker

  ✓  1 …e/setup/addUsersAndLicense.spec.ts:7:5 › setup deployment (8.7s)
     2 ….ts:79:5 › create workspace with default and required parameters
[console][error] Failed to load resource: the server responded with a status of 401 (Unauthorized)
[console][error] Failed to load resource: the server responded with a status of 401 (Unauthorized)
[response] url=http://localhost:3111/api/v2/users/me/appearance status=401 body={"message":"You are signed out or your session has expired. Please sign in again to continue.","detail":"Cookie \"coder_session_token\" or query parameter must be provided."}
[response] url=http://localhost:3111/api/v2/users/me status=401 body={"message":"You are signed out or your session has expired. Please sign in again to continue.","detail":"Cookie \"coder_session_token\" or query parameter must be provided."}
[console][warning] Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq
[console][warning] You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker
  ✓  2 …5 › create workspace with default and required parameters (7.1s)atus of 401 (Unauthorized)
[console][error] Failed to load resource: the server responded with a status of 401 (Unauthorized)
[response] url=http://localhost:3111/api/v2/users/me/appearance status=401 body={"message":"You are signed out or your session has expired. Please sign in again to continue.","detail":"Cookie \"coder_session_token\" or query parameter must be provided."}
[response] url=http://localhost:3111/api/v2/users/me status=401 body={"message":"You are signed out or your session has expired. Please sign in again to continue.","detail":"Cookie \"coder_session_token\" or query parameter must be provided."}

  2 passed (32.0s)

9 LOL (Lines of logs)

@jakehwll jakehwll changed the title chore: remove api.ts unnecessary calls chore!: remove api.ts unnecessary calls Feb 18, 2026
Comment thread site/src/pages/TasksPage/TasksTable.tsx Outdated
@github-actions github-actions Bot added the stale This issue is like stale bread. label Mar 4, 2026
@github-actions github-actions Bot closed this Mar 8, 2026
@jakehwll jakehwll reopened this Apr 6, 2026
@jakehwll jakehwll removed the stale This issue is like stale bread. label Apr 6, 2026
@jakehwll jakehwll requested a review from jeremyruppel April 6, 2026 11:20
@jakehwll jakehwll marked this pull request as ready for review April 6, 2026 11:21
@github-actions github-actions Bot added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Apr 6, 2026
Comment thread site/src/pages/CreateTemplatePage/CreateTemplateForm.tsx Outdated
@jakehwll jakehwll requested a review from jeremyruppel April 6, 2026 18:01
Copy link
Copy Markdown
Contributor

@jeremyruppel jeremyruppel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! calling out the 404 → 204 as a breaking change is the right thing to do, and I would be surprised if any other clients depend on the 404 response 👍

- Change previousTemplateVersion endpoint to return 204 instead of 404
  when no previous version exists.
- Add ErrNoPreviousVersion sentinel error in codersdk.
- Remove unnecessary deployment stats queries when user lacks permission.
- Add enabled guards for provisioner queries when organization is undefined.
- Use Boolean() for react-query enabled props consistency.
- Simplify TasksTable checkbox checked expression.
@jakehwll jakehwll force-pushed the jakehwll/react-query-enabled-cleanup branch from abd4c1d to 4308d3c Compare April 21, 2026 13:41
@jakehwll jakehwll merged commit 4caa528 into main Apr 22, 2026
29 of 31 checks passed
@jakehwll jakehwll deleted the jakehwll/react-query-enabled-cleanup branch April 22, 2026 20:20
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release/breaking This label is applied to PRs to detect breaking changes as part of the release process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants