feat: Forward endpoint URL to migrations package#165
Conversation
Resolve the active environment's API base URL and pass it via WORKOS_API_URL env var so the migrations package respects custom endpoints (staging, self-hosted, etc.). Resolves ENT-6103 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Original prompt from jonatas
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThis PR forwards the active CLI environment's
Confidence Score: 5/5Safe to merge — the env var is set only when a custom endpoint is present, preserving existing shell-set values when no CLI environment endpoint is configured. The call site correctly uses getActiveEnvironment()?.endpoint which returns undefined when no custom endpoint exists, so WORKOS_API_URL is never unconditionally overwritten. The function guard if (apiBaseUrl) is consistent with the existing WORKOS_SECRET_KEY pattern, tests cover both paths, and beforeEach teardown prevents cross-test pollution. No files require special attention. Important Files Changed
|
Avoid clobbering a user-set WORKOS_API_URL env var when no custom endpoint is configured. Use getActiveEnvironment()?.endpoint which returns undefined when no custom endpoint exists. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
The
workos migrationswrapper previously only forwardedWORKOS_SECRET_KEYto the migrations package. Users with custom endpoints (staging, self-hosted) had no way to direct migration API calls to their target environment.Now
runMigrations()accepts an optionalapiBaseUrlparam (resolved from the CLI's active environment viaresolveApiBaseUrl()). When present, it setsWORKOS_API_URLin the process env before invoking the migrations CLI — the migrations package reads this env var to configure the SDK client'sapiHostname.Resolves https://linear.app/workos/issue/ENT-6103/fix-cli-gaps-found-in-200k-import-load-test
Link to Devin session: https://app.devin.ai/sessions/27dc2a764fe546458f3e28cf7f24bc28
Requested by: @jonatascastro12