{"record":{"id":"9061718ba693d31f","repo":"tursodatabase/turso","slug":"http-request-missing-url-no-url-in-request-and-no","errorCode":null,"errorMessage":"HTTP request missing URL: no URL in request and no baseUrl in context","messagePattern":"HTTP request missing URL: no URL in request and no baseUrl in context","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bindings/react-native/src/internal/ioProcessor.ts","lineNumber":162,"sourceCode":"    return context.baseUrl() ?? null;\n  }\n\n  return context.baseUrl;\n}\n\n/**\n * Process an HTTP request using fetch()\n *\n * @param item - The IO item\n * @param context - IO context with auth and URL information\n */\nasync function processHttpRequest(item: NativeSyncIoItem, context: IoContext): Promise<void> {\n  const request = item.getHttpRequest();\n\n  // Resolve base URL: prefer context.baseUrl (from opts), fall back to request.url\n  const rawBaseUrl = getBaseUrl(context) ?? request.url;\n  if (!rawBaseUrl) {\n    throw new Error('HTTP request missing URL: no URL in request and no baseUrl in context');\n  }\n\n  // Normalize URL (libsql:// -> https://)\n  const baseUrl = normalizeUrl(rawBaseUrl);\n\n  // Build full URL by combining base URL with path\n  let fullUrl = baseUrl;\n  if (request.path) {\n    // Ensure proper URL formatting (avoid double slashes, ensure single slash)\n    if (baseUrl.endsWith('/') && request.path.startsWith('/')) {\n      fullUrl = baseUrl + request.path.substring(1);\n    } else if (!baseUrl.endsWith('/') && !request.path.startsWith('/')) {\n      fullUrl = baseUrl + '/' + request.path;\n    } else {\n      fullUrl = baseUrl + request.path;\n    }\n  }\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/react-native/src/internal/ioProcessor.ts#L144-L180","documentation":"When the sync engine emits an HTTP IO item, processHttpRequest() must produce a full URL: it prefers the baseUrl from the connect() context (getBaseUrl(context)) and falls back to the URL embedded in the request itself. If both are absent there is nowhere to send the request, and it throws before any network activity. This is a configuration error, not a network failure.","triggerScenarios":"Calling connect({ path }) with no url and then triggering IO (any query needing remote pages, or sync); an opts object whose url is undefined or empty string (e.g. a missing environment variable); constructing the Database with a context that never carried a baseUrl.","commonSituations":"Forgetting url in local-first usage that later needs remote pages; env vars not loaded before connect() in React Native (no automatic .env support); passing url only in a nested/wrongly named option key.","solutions":["Pass a valid url in the connect() options so the IO context has a baseUrl","Verify the url value is a non-empty string at runtime (log it before connect) and that env vars are actually loaded","Check the option name and nesting against the connect() signature — a typo'd key silently leaves url undefined","If the request should be purely local, avoid operations that require remote pages until a url is configured"],"exampleFix":"// before\nconst db = await connect({ path: dbPath }); // later throws: HTTP request missing URL\n\n// after\nconst db = await connect({\n  path: dbPath,\n  url: 'https://my-db-my-org.turso.io',\n  authToken: myToken,\n});","handlingStrategy":"validation","validationCode":"function assertConnectOpts(opts: { url?: string; authToken?: string }): void {\n  if (typeof opts.url !== 'string' || opts.url.trim() === '') {\n    throw new Error('connect(): url is required for sync IO — got ' + JSON.stringify(opts.url));\n  }\n}\n\nassertConnectOpts(opts);\nconst db = await connect(opts);","typeGuard":"function hasSyncUrl(opts: unknown): opts is { url: string } {\n  return typeof (opts as { url?: unknown })?.url === 'string' &&\n    (opts as { url: string }).url.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Fail fast on missing url at the call site instead of during the first remote page fetch","Load env config (e.g. react-native-config or inline constants) before connect() and assert it","Remember this is a config error — retries and network fixes will not help"],"tags":["configuration","missing-url","sync","react-native"],"backgroundTag":"missing-connection-url","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}