{"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/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/react-native/src/internal/ioProcessor.ts#L144-L180","documentation":"The sync engine emitted an HTTP IO item, but the request carried no URL and the IoContext has no usable baseUrl (the url from your connect options). processHttpRequest refuses to guess and throws. The IoContext baseUrl is only populated from DatabaseOpts.url, and empty strings and null-returning url functions both count as missing.","triggerScenarios":"Opening a Database with url: '' (empty string still selects sync mode via isSyncConfig) and then calling connect()/pull()/push(); passing url as a function that returns null; invoking a network-touching operation on a database whose sync options were never wired.","commonSituations":"url built from an env/config variable that is undefined in the release build, producing '' after template-string interpolation; a url provider function that returns null before a remote config fetch completes.","solutions":["Pass a concrete url (e.g. libsql://mydb.turso.io) in the connect options whenever you intend to sync","If url is a function, make it return the real URL string (or throw early) - never null","Fail fast at startup: validate that opts.url is a non-empty string before calling connect"],"exampleFix":"// before\nconst db = new Database({ path: 'replica.db', url: process.env.SYNC_URL }); // '' in release\n\n// after - fail fast on missing configuration\nconst url = process.env.SYNC_URL;\nif (!url) throw new Error('SYNC_URL is required for sync mode');\nconst db = await connect({ path: 'replica.db', url });","handlingStrategy":"validation","validationCode":"function assertSyncUrl(opts: DatabaseOpts): void {\n  const url = typeof opts.url === 'function' ? opts.url() : opts.url;\n  if (opts.path !== ':memory:' && !url) {\n    throw new Error('A non-empty url is required for sync mode');\n  }\n}\n// call before connect(opts)","typeGuard":"function hasSyncUrl(opts: DatabaseOpts): boolean {\n  const url = typeof opts.url === 'function' ? opts.url() : opts.url;\n  return typeof url === 'string' && url.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Never interpolate possibly-undefined config into url - assert the env value first","url provider functions must return the string or throw, never null","Treat an empty-string url as a configuration bug and reject it at startup"],"tags":["react-native","sync","url","configuration","validation"],"backgroundTag":"missing-database-url","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}