{"record":{"id":"bc6fb01fc368220c","repo":"microsoft/typescript-go","slug":"errinvalidrequest","errorCode":"ErrInvalidRequest","errorMessage":"api: invalid request","messagePattern":"api: invalid request","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/api/proto.go","lineNumber":24,"sourceCode":"\n\t\"github.com/microsoft/typescript-go/internal/ast\"\n\t\"github.com/microsoft/typescript-go/internal/checker\"\n\t\"github.com/microsoft/typescript-go/internal/collections\"\n\t\"github.com/microsoft/typescript-go/internal/core\"\n\t\"github.com/microsoft/typescript-go/internal/diagnostics\"\n\t\"github.com/microsoft/typescript-go/internal/jsnum\"\n\t\"github.com/microsoft/typescript-go/internal/json\"\n\t\"github.com/microsoft/typescript-go/internal/locale\"\n\t\"github.com/microsoft/typescript-go/internal/ls/lsconv\"\n\t\"github.com/microsoft/typescript-go/internal/lsp/lsproto\"\n\t\"github.com/microsoft/typescript-go/internal/packagejson\"\n\t\"github.com/microsoft/typescript-go/internal/project\"\n\t\"github.com/microsoft/typescript-go/internal/tsoptions\"\n\t\"github.com/microsoft/typescript-go/internal/tspath\"\n)\n\nvar (\n\tErrInvalidRequest = errors.New(\"api: invalid request\")\n\tErrClientError    = errors.New(\"api: client error\")\n)\n\ntype Method string\n\ntype (\n\tSnapshotID  uint64\n\tProjectID   string\n\tSymbolID    uint64\n\tTypeID      uint32\n\tSignatureID uint64\n\tNodeHandle  string\n)\n\nfunc ProjectHandle(p *project.Project) ProjectID {\n\treturn ProjectID(p.ID())\n}\n","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/api/proto.go#L6-L42","documentation":"Sentinel error marking caller-side malformed input. It is wrapped by the msgpack framing checks in protocol_msgpack.go (bad tuple marker, bad type marker, unknown type, bad binary marker) and by request validation failures in session.go. errors.Is(err, api.ErrInvalidRequest) distinguishes 'the client sent garbage' from server-side failures; the wrapped text carries specifics.","triggerScenarios":"A msgpack stream whose tuple/type/bin marker bytes are wrong (desync or wrong wire format); a request whose params fail server-side validation and get wrapped at dispatch.","commonSituations":"Speaking plain JSON-RPC or LSP Content-Length framing into a MessagePackProtocol connection; a non-Go client with a buggy tuple encoder; payloads not matching the method schema.","solutions":["Read the text after the sentinel for the precise framing or validation cause","Ensure both endpoints construct the matching Protocol implementation over the transport","Fix the offending payload per the method's documented params type","When writing a client in another language, mirror the frame format exactly: 0x93, type byte, bin8/16/32 method, bin8/16/32 payload"],"exampleFix":"// before\nproto := api.NewMessagePackProtocol(jsonRpcConn) // wrong framing\n\n// after\nproto := api.NewMessagePackProtocol(msgpackConn) // both ends msgpack tuples","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isInvalidRequest(err error) bool { return errors.Is(err, api.ErrInvalidRequest) }","tryCatchPattern":"err := conn.Run(ctx)\nif err != nil && errors.Is(err, api.ErrInvalidRequest) {\n\t// client sent malformed framing; message text after the sentinel says what\n\tlog.Printf(\"malformed client input: %v\", err)\n\treturn nil // drop the connection quietly\n}","preventionTips":["Use the same Protocol implementation on both ends of the transport","Mirror the tuple format exactly in non-Go clients","Test framing with golden byte fixtures"],"tags":["go","sentinel","invalid-request","msgpack","framing","validation"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}