{"record":{"id":"26ace46a8cfa0141","repo":"Stirling-Tools/Stirling-PDF","slug":"server-configuration-not-found","errorCode":null,"errorMessage":"Server configuration not found","messagePattern":"Server configuration not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/editor/src/desktop/services/operationRouter.ts","lineNumber":310,"sourceCode":"    const target = await this.getExecutionTarget(operation);\n\n    if (target === \"local\") {\n      // Use dynamically assigned port from backend service\n      const backendUrl = tauriBackendService.getBackendUrl();\n      if (!backendUrl) {\n        throw new Error(\n          \"Backend URL not available - backend may still be starting\",\n        );\n      }\n      // Strip trailing slash to avoid double slashes in URLs\n      return backendUrl.replace(/\\/$/, \"\");\n    }\n\n    // Remote: get from server config\n    const serverConfig = await connectionModeService.getServerConfig();\n    if (!serverConfig) {\n      console.warn(\"No server config found\");\n      throw new Error(\"Server configuration not found\");\n    }\n\n    // Strip trailing slash to avoid double slashes in URLs\n    return serverConfig.url.replace(/\\/$/, \"\");\n  }\n\n  /**\n   * Checks if we're currently in self-hosted mode\n   */\n  async isSelfHostedMode(): Promise<boolean> {\n    const mode = await connectionModeService.getCurrentMode();\n    return mode === \"selfhosted\";\n  }\n\n  /**\n   * Checks if we're currently in SaaS mode\n   */\n  async isSaaSMode(): Promise<boolean> {","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/desktop/services/operationRouter.ts#L292-L328","documentation":"Thrown on the remote-routing branch of getBaseUrlForOperation() when connectionModeService.getServerConfig() returns a falsy value. The remote branch is reached only when getExecutionTarget() !== 'local', so this means a remote/self-hosted-server target was chosen but no server configuration (URL + credentials) is persisted. The returned serverConfig.url is otherwise used verbatim (trailing slash stripped).","triggerScenarios":"getExecutionTarget() returns a remote target but getServerConfig() yields null/undefined. Happens when the connection-mode store has no saved server (user never connected) or the persisted config was cleared/corrupted while the mode still implies a remote server.","commonSituations":"User selected self-hosted/remote mode but never completed the 'connect to server' flow; a config migration reset the stored server config; the config load is async and was queried before it resolved.","solutions":["Ensure the user has completed server onboarding (connectionModeService should have a non-null config) before allowing remote-targeted operations.","Check that getServerConfig() is awaited and its underlying store has loaded before the router runs.","If the config was intentionally cleared, force the mode back to local so getExecutionTarget returns 'local' instead of remote.","Surface a 'please reconnect your server' prompt in the UI when this throws, rather than a raw error."],"exampleFix":"// before\nconst serverConfig = await connectionModeService.getServerConfig();\nif (!serverConfig) {\n  throw new Error(\"Server configuration not found\");\n}\nreturn serverConfig.url.replace(/\\/$/, \"\");\n\n// after — typed error + clear recovery path for the UI\nconst serverConfig = await connectionModeService.getServerConfig();\nif (!serverConfig) throw new NoServerConfigError();\nreturn serverConfig.url.replace(/\\/$/, \"\");","handlingStrategy":"validation","validationCode":"import { connectionModeService } from \"@app/desktop/services/connectionModeService\";\n\nasync function hasServerConfig(): Promise<boolean> {\n  return (await connectionModeService.getServerConfig()) != null;\n}\n// guard remote-targeted operations: if (!await hasServerConfig()) promptReconnect();","typeGuard":"function isNoServerConfig(e: unknown): boolean {\n  return e instanceof Error && /Server configuration not found/.test(e.message);\n}","tryCatchPattern":"try {\n  const base = await router.getBaseUrlForOperation(operation);\n} catch (e) {\n  if (isNoServerConfig(e)) { promptReconnectServer(); return; }\n  throw e;\n}","preventionTips":["Complete server onboarding before enabling remote operations.","Await getServerConfig()'s underlying store load before routing.","Force local mode if the server config was intentionally cleared."],"tags":["desktop","operation-routing","connection-mode","config"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}