{"record":{"id":"92168887e178e9ec","repo":"transloadit/uppy","slug":"res-sendstatus-400-921688","errorCode":null,"errorMessage":"res.sendStatus(400)","messagePattern":"res\\.sendStatus\\(400\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"packages/@uppy/companion/src/server/controllers/search.ts","lineNumber":12,"sourceCode":"import type { NextFunction, Request, Response } from 'express'\nimport { respondWithError } from '../provider/error.js'\n\nexport default async function search(\n  req: Request,\n  res: Response,\n  next: NextFunction,\n): Promise<void> {\n  const { query, companion } = req\n  const { providerUserSession, provider } = companion\n  if (!provider) {\n    res.sendStatus(400)\n    return\n  }\n\n  const buildURL = companion.buildURL\n  const q = query['q']\n  if (buildURL == null || typeof q !== 'string') {\n    res.sendStatus(500)\n    return\n  }\n\n  try {\n    const data = await provider.search({\n      companion: { buildURL },\n      providerUserSession,\n      query: { ...query, q },\n    })\n    res.json(data)\n  } catch (err) {","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/transloadit/uppy/blob/5d4dedd02a1ac0ae022c75c54aca76558f88e256/packages/@uppy/companion/src/server/controllers/search.ts#L1-L30","documentation":"The Companion search controller returns HTTP 400 when no provider handler is attached to the request (req.companion.provider is falsy). This means the route was hit for a providerName that Companion could not instantiate or does not have enabled, so it cannot forward the search request.","triggerScenarios":"Calling GET /search/:providerName?q=... where the provider middleware failed to attach req.companion.provider (unknown/disabled/unconfigured provider, e.g. missing credentials, or provider options invalid so it was not loaded).","commonSituations":"Requesting search on a non-search-capable provider, typo in providerName, provider disabled in companion options, or invalid provider options causing the provider middleware to skip loading.","solutions":["Verify the providerName in the URL matches an enabled provider (e.g. 'unsplash', 'drive')","Check companion options: provider must be listed and have valid credentials","Inspect logs for 'provider.middleware.invalid' / 'invalid provider options detected' warnings at startup","Ensure the request goes through the full Companion middleware chain (not hitting the controller directly)"],"exampleFix":"// before\ncompanionOptions: { providerOptions: {} } // no credentials\n// after\ncompanionOptions: { providerOptions: { unsplash: { key: process.env.UNSPLASH_KEY, secret: process.env.UNSPLASH_SECRET } } }","handlingStrategy":"validation","validationCode":"const enabled = await fetch(`${companionUrl}/`).then(r => r.json());\nif (!enabled.some(p => p.providerName === name)) throw new Error('provider not enabled')","typeGuard":"const isEnabledProvider = (name: string, providers: {providerName: string}[]) => providers.some(p => p.providerName === name)","tryCatchPattern":null,"preventionTips":["Check Companion's index route for enabled providers before using one","Configure all provider credentials at startup"],"tags":["companion","provider","http-400","search"],"backgroundTag":"invalid-request-parameters","analyzedSha":"5d4dedd02a1ac0ae022c75c54aca76558f88e256","analyzedAt":"2026-08-28T12:18:41.267Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}