{"record":{"id":"14f11999b00d272d","repo":"payloadcms/payload","slug":"request-url-is-missing","errorCode":null,"errorMessage":"Request URL is missing.","messagePattern":"Request URL is missing\\.","errorType":"http","errorClass":"APIError","httpStatus":400,"severity":"error","filePath":"packages/payload/src/uploads/endpoints/getFileFromURL.ts","lineNumber":45,"sourceCode":"    throw new APIError('Pasting from URL is not enabled for this collection.', 400)\n  }\n\n  if (id) {\n    // updating doc\n    const accessResult = await executeAccess({ slug: config.slug, req }, config.access.update)\n    if (!accessResult) {\n      throw new Forbidden(req.t)\n    }\n  } else {\n    // creating doc\n    const accessResult = await executeAccess({ slug: config.slug, req }, config.access?.create)\n    if (!accessResult) {\n      throw new Forbidden(req.t)\n    }\n  }\n\n  if (!req.url) {\n    throw new APIError('Request URL is missing.', 400)\n  }\n\n  const { searchParams } = new URL(req.url)\n  const src = searchParams.get('src')\n\n  if (!src || typeof src !== 'string') {\n    throw new APIError('A valid URL string is required.', 400)\n  }\n\n  const hasAllowList =\n    typeof config.upload.pasteURL === 'object' && Array.isArray(config.upload.pasteURL.allowList)\n\n  let fileURL: string\n  try {\n    fileURL = new URL(src).href\n  } catch {\n    throw new APIError('A valid URL string is required.', 400)\n  }","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/uploads/endpoints/getFileFromURL.ts#L27-L63","documentation":"APIError (HTTP 400, 'Request URL is missing.') thrown when req.url is falsy at the point of building search params. This is a framework-level precondition: the Hono/express request must carry a URL so that `new URL(req.url)` can parse query string.","triggerScenarios":"The handler is invoked through a code path that didn't set req.url (e.g. a programmatic/internal call, a custom endpoint wrapper, or a misrouted request). In normal HTTP traffic this essentially never fires.","commonSituations":"Calling the handler directly from server code without a synthesized PayloadRequest; a test harness building an incomplete req object; an exotic proxy stripping the request line; middleware that nulls req.url.","solutions":["Always reach the endpoint over HTTP via the registered route rather than calling the handler programmatically.","In tests, build a PayloadRequest with a populated url (including the ?src= query).","If invoking internally, synthesize req: { url: '/api/.../paste-url?src=...', ... }.","Inspect any middleware that may be clearing req.url before the handler."],"exampleFix":"// test — before\nconst res = await getFileFromURLHandler({ user, payload } as any)\n// after — include url\nconst res = await getFileFromURLHandler({\n  user, payload,\n  url: '/api/media/paste-url?src=https://cdn.example.com/x.png',\n  searchParams: new URLSearchParams({ src: 'https://cdn.example.com/x.png' }),\n} as any)","handlingStrategy":"validation","validationCode":"function requestHasUrl(req: { url?: string }): boolean {\n  return typeof req?.url === 'string' && req.url.length > 0\n}\n// in tests:\nif (!requestHasUrl(mockReq)) throw new Error('Test req missing url')","typeGuard":"const hasUrl = (req: { url?: string }): req is { url: string } =>\n  typeof req?.url === 'string' && req.url.length > 0","tryCatchPattern":"try {\n  await getFileFromURLHandler(req)\n} catch (e) {\n  if (/Request URL is missing/.test(e.message)) throw new Error('Programming error: handler called without req.url')\n}","preventionTips":["Always invoke the handler through the registered HTTP route.","In tests, build a complete PayloadRequest including url + searchParams.","Avoid middleware that strips req.url.","Document the handler's precondition that req.url be set."],"tags":["upload","paste-url","request","framework"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}