ErrLookup › Background articles › BAD_REQUEST error code: request rejected as invalid (HTTP 400) - causes and fixes across libraries
BAD_REQUEST error code: request rejected as invalid (HTTP 400) - causes and fixes across libraries
BAD_REQUEST is the error code libraries use for HTTP 400 semantics: the request is malformed, fails validation, or violates a precondition, and the server refuses it before doing any real work. Developers meet it as a tRPC TRPCError in applications like LobeChat and Reactive Resume, as HTTP 400 from Harbor's policy and configuration checks, as Astro's AstroActionInputError carrying serialized Zod issues back to the browser, and as Sentinel's cluster-transport rejection of a malformed request. This article explains the mechanism behind the family, the causes that recur across libraries, and the remediation themes that hold everywhere.
Distilled from 88 documented records across 8 repositories.
Background
BAD_REQUEST carries HTTP 400 semantics into a library's own error system: the request is invalid on arrival, and the receiving code refuses to process it further. In tRPC-based applications such as LobeChat and Reactive Resume it is a TRPCError with code 'BAD_REQUEST', thrown deliberately by a validation guard at the top of a procedure before any side effects run. In Harbor it is the HTTP 400 returned when a schema or rule check rejects a preheat policy, configuration update, replication rule, or artifact request. In Astro, when a server action's Zod validation fails, the server serializes its issues and the client re-throws them as an AstroActionInputError with code 'BAD_REQUEST'. Sentinel's cluster transport and tRPC's HTTP adapter sit at the same boundary from the other side: a malformed request object or request line is rejected before application logic ever sees it. The family exists to separate caller bugs from server faults; the code is the server saying the problem is in what was sent, not in how it was processed.
From the caller's side the family behaves consistently. The failure is synchronous and deterministic, so retrying the identical request fails identically; this is not a transient condition. The message usually carries the evidence needed for a fix: Astro embeds the JSON array of Zod issues and groups messages by field in error.fields; Harbor formats the offending value into the message, whether the cron string that failed to parse, the repository path too shallow for the configured flattening level, or the content type sniffed from an icon layer; LobeChat passes an embedding provider's business reason through verbatim, and its bot-settings validator surfaces whichever field violated the access policy. A bare message such as Sentinel's 'bad request' for a null or untyped ClusterRequest means the library found the request internally inconsistent, and the caller must inspect the code that built it.
What varies across the family is the layer that rejects. Some records are pure input-shape validation: a negative file size in LobeChat, a date outside strict YYYY-MM-DD in Reactive Resume, a fallback fingerprint that is not 64-character lowercase hex. Others are business-rule preconditions: LobeChat refuses an agent or chat group whose visibility conflicts with the target folder, and Harbor rejects a replication rule whose flattening level exceeds the source repository's path depth, or an LDAP group update whose merged effective configuration leaves the name attribute empty. Some are security and trust-boundary guards: open-design's importer refuses repositories containing symbolic links to prevent file exfiltration, and Harbor sniffs artifact icon layers and accepts only GIF, PNG, or JPEG. A few encode state mismatches, such as Reactive Resume refusing an answer whose toolCallId matches no unanswered question. Classification is library-specific: LobeChat reports a missing operation ID as BAD_REQUEST rather than a 404, and an embedding provider's business error surfaces as BAD_REQUEST rather than a server error, so do not infer fault or retry semantics from the code alone.
Common causes
- Input fails schema validation. A required field is missing, a value has the wrong type, or a number is out of range. Examples: a negative file size passed to LobeChat's file upload, an Astro server action payload that violates its Zod schema, or a Reactive Resume PDF-fallback fingerprint that is not 64-character lowercase hex.
- Malformed format strings. Dates outside strict YYYY-MM-DD, a five-field crontab string where Harbor expects six fields with a literal 0 for seconds, an AI provider baseURL that fails URL normalization, a LobeChat import file that fails JSON.parse, or a Host header bad enough to break tRPC's URL construction.
- Conflicting state or partial configuration. The payload is well-formed but disagrees with stored state: an agent or chat-group visibility that conflicts with the target folder in LobeChat, a Harbor LDAP partial update whose merged effective config is invalid, or a replication flattening level deeper than the source path allows.
- Missing context or credential. The call needs ambient state that was not supplied: sharing a credential or setting topic visibility without an active workspace in LobeChat, or calling OIDC userinfo with neither a token in the body nor a trusted-client session.
- Unsupported or stale values. An enum value outside the supported set or an identifier that no longer resolves: a bot platform outside discord, slack, telegram, feishu, lark, qq, wechat; a deprecated image model id; an operationId with no matching running operation; a topic with no agent binding and no agentId override in a notify call.
- Operation unsupported for the target type. The endpoint exists but not for this kind of target: requesting additions on a custom artifact with no registered processor in Harbor, or reading a resource from a LobeChat skill whose manifest declares none.
- Security and trust-boundary guards. Content is rejected to prevent abuse rather than because it is unusable: open-design refuses imports of repositories containing symbolic links, and Harbor rejects artifact icon layers sniffed as anything other than GIF, PNG, or JPEG.
What usually fixes it
- [object Object]
- [object Object]
- [object Object]
- [object Object]
- [object Object]
- [object Object]
Go deeper
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
Documented occurrences
- BAD_REQUEST: File size cannot be negative (lobehub/lobehub)
- BAD_REQUEST: A ${requested} chat group cannot be created in a ${folderVisibility} folder (lobehub/lobehub)
- BAD_REQUEST: Sharing a credential requires an active workspace context (lobehub/lobehub)
- BAD_REQUEST: A ${input.visibility} agent cannot be created in a ${folderVisibility} folder (lobehub/lobehub)
- BAD_REQUEST: Date must use YYYY-MM-DD format. (amruthpillai/reactive-resume)
- BAD_REQUEST: invalid cron string for scheduled preheat: %s, error: %v (goharbor/harbor)
- BAD_REQUEST: Topic ${topicId} has no associated agent and no agentId was provided (lobehub/lobehub)
- BAD_REQUEST: Invalid AI provider configuration. (amruthpillai/reactive-resume)
- BAD_REQUEST: Unsupported platform: ${platform} (lobehub/lobehub)
- BAD_REQUEST: Token is required for userinfo (lobehub/lobehub)
- BAD_REQUEST: No matching unanswered user question was found. (amruthpillai/reactive-resume)
- BAD_REQUEST: Invalid URL (trpc/trpc)
- BAD_REQUEST: Skill has no resources (lobehub/lobehub)
- BAD_REQUEST: the source repository %q contains only %d path components %v excepting the last one, but the destination namespace flattening level is %d (goharbor/harbor)
- BAD_REQUEST: Failed to read file at ${input.pathname} (lobehub/lobehub)
- BAD_REQUEST: bad request (alibaba/Sentinel)
- BAD_REQUEST: addition %s isn't supported (goharbor/harbor)
- BAD_REQUEST: ldap group name attribute can not be empty (goharbor/harbor)
- BAD_REQUEST: ${error.message} (lobehub/lobehub)
- BAD_REQUEST: Provider service error (lobehub/lobehub)
…and 68 more across the corpus — use search.
Honest provenance: generated on 2026-08-24 from AI-assisted analysis of the linked records. See how records are made.