Skip to content

fix: ensure coder user accounts are always activated before use#322

Open
arian81 wants to merge 1 commit intomainfrom
fix-ensure-coder-user-accounts-are-always-activated-before-use
Open

fix: ensure coder user accounts are always activated before use#322
arian81 wants to merge 1 commit intomainfrom
fix-ensure-coder-user-accounts-are-always-activated-before-use

Conversation

@arian81
Copy link
Copy Markdown
Contributor

@arian81 arian81 commented Mar 24, 2026

Create a helper function that can be wrapped around coder interactions to make sure user account is always active before doing the action

Coder marks accounts as dormant after inactivity, which can break
workspace and submission flows. Extract shared ensureUserActive()
helper and call it in both launchWorkspace and triggerSubmission.
Copy link
Copy Markdown
Contributor Author

arian81 commented Mar 24, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arian81 arian81 requested a review from Krish120003 March 24, 2026 21:30
@arian81 arian81 marked this pull request as ready for review March 24, 2026 21:30
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR centralizes Coder user-account activation by extracting an ensureUserActive helper into helpers/coder.ts and applying it consistently before Coder interactions in both launchWorkspace and triggerSubmission. The change is small and well-scoped.

  • New helper ensureUserActive — wraps activateUserAccount from the SDK and throws on failure, following the same pattern as the existing ensureWorkspaceRunning helper.
  • launchWorkspace — replaces the inline activation block (which silently swallowed errors) with ensureUserActive. This is an intentional behavioral change: activation failures now abort the action rather than being silently ignored.
  • triggerSubmission — adds an ensureUserActive call before ensureWorkspaceRunning, correctly wrapped in a try-catch that calls internalFailSubmission before re-throwing, consistent with the surrounding error-handling pattern.
  • Missing issue link — the PR description does not include a resolves #issue-id reference as required by the contribution policy.

Confidence Score: 4/5

  • Safe to merge once the intentional behavioral change in launchWorkspace is confirmed and an issue link is added to the PR description.
  • The code is clean and the helper is well-structured. The only substantive concern is the deliberate change from silently ignoring activation errors to throwing them in launchWorkspace — this is almost certainly the right move, but should be explicitly acknowledged. The PR also lacks the required resolves #issue-id link.
  • packages/backend/convex/web/assignmentActions.ts — confirm that surfacing activation errors to callers is the intended behavior change.

Important Files Changed

Filename Overview
packages/backend/convex/helpers/coder.ts Adds ensureUserActive helper that wraps activateUserAccount and throws on error. Clean extraction, well-documented, consistent with existing ensureWorkspaceRunning pattern.
packages/backend/convex/web/assignmentActions.ts Replaces inline activation code (which silently swallowed errors) with ensureUserActive. This is a deliberate behavioral change — activation failures now abort the launch instead of being silently ignored.
packages/backend/convex/web/submissionActions.ts Adds ensureUserActive call before workspace operations, correctly wrapped in a try-catch that marks the submission as failed before re-throwing — consistent with the surrounding error-handling pattern.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: packages/backend/convex/web/assignmentActions.ts
Line: 89

Comment:
**Behavioral change: activation failures now throw**

The original code explicitly silenced activation errors with `// Don't throw here - continue with workspace launch even if activation fails`. The new `ensureUserActive` call will now throw and abort the entire `launchWorkspace` action if the Coder activation endpoint fails. This is almost certainly the intended improvement (the PR description says "always activated before use"), but it's worth confirming this trade-off is acceptable — workspace launches that previously succeeded despite a dormant-activation failure will now surface as errors to the caller.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix: ensure coder user accounts are alwa..." | Re-trigger Greptile

if (activateResp.error) {
// Don't throw here - continue with workspace launch even if activation fails
}
await ensureUserActive({ client: coderClient, userId: coderUserId });
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Behavioral change: activation failures now throw

The original code explicitly silenced activation errors with // Don't throw here - continue with workspace launch even if activation fails. The new ensureUserActive call will now throw and abort the entire launchWorkspace action if the Coder activation endpoint fails. This is almost certainly the intended improvement (the PR description says "always activated before use"), but it's worth confirming this trade-off is acceptable — workspace launches that previously succeeded despite a dormant-activation failure will now surface as errors to the caller.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/backend/convex/web/assignmentActions.ts
Line: 89

Comment:
**Behavioral change: activation failures now throw**

The original code explicitly silenced activation errors with `// Don't throw here - continue with workspace launch even if activation fails`. The new `ensureUserActive` call will now throw and abort the entire `launchWorkspace` action if the Coder activation endpoint fails. This is almost certainly the intended improvement (the PR description says "always activated before use"), but it's worth confirming this trade-off is acceptable — workspace launches that previously succeeded despite a dormant-activation failure will now surface as errors to the caller.

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant