fix: avoid derp-related panic during wsproxy registration#22322
Merged
deansheather merged 1 commit intomainfrom Feb 26, 2026
Merged
fix: avoid derp-related panic during wsproxy registration#22322deansheather merged 1 commit intomainfrom
deansheather merged 1 commit intomainfrom
Conversation
If the primary had DERP disabled, workspace proxy registrations would fail with a panic, as the registration endpoint would attempt to access the mesh key from the nil DerpServer. Changes the endpoint to query the database for the key.
Emyrk
approved these changes
Feb 26, 2026
| err := options.Database.InTx(func(tx database.Store) error { | ||
| // This will block until the lock is acquired, and will be | ||
| // automatically released when the transaction ends. | ||
| err := tx.AcquireLock(ctx, database.LockIDEnterpriseDeploymentSetup) |
Comment on lines
+607
to
+624
| // Load the mesh key directly from the database. We don't retrieve the mesh | ||
| // key from the built-in DERP server because it may not be enabled. | ||
| // | ||
| // The mesh key is always generated at startup by an enterprise coderd | ||
| // server. | ||
| var meshKey string | ||
| if req.DerpEnabled { | ||
| var err error | ||
| meshKey, err = api.Database.GetDERPMeshKey(ctx) | ||
| if err != nil { | ||
| httpapi.InternalServerError(rw, xerrors.Errorf("get DERP mesh key: %w", err)) | ||
| return | ||
| } | ||
| if meshKey == "" { | ||
| httpapi.InternalServerError(rw, xerrors.New("mesh key is empty")) | ||
| return | ||
| } | ||
| } |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
If the primary had DERP disabled, workspace proxy registrations would fail with a panic, as the registration endpoint would attempt to access the mesh key from the nil DerpServer.
Changes the endpoint to query the database for the key.
Closes #22317