{"record":{"id":"d8f38eda718cf729","repo":"JuliusBrussee/caveman","slug":"kms-unknown-envelope-format","errorCode":null,"errorMessage":"kms: unknown envelope format","messagePattern":"kms: unknown envelope format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/kms/kms.go","lineNumber":224,"sourceCode":"\t}\n\treturn client.Decrypt(ctx, blob)\n}\n\n// DecryptPayload unwraps an artifact data key with the dedicated payload KEK,\n// while allowing the explicitly configured legacy secrets key during cutover.\nfunc DecryptPayload(ctx context.Context, blob []byte) ([]byte, error) {\n\tclient, err := FromPayloadEnvironment()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn client.Decrypt(ctx, blob)\n}\n\n// Decrypt unwraps versioned KMS envelope. Metadata can choose only validated\n// key identity under configured provider; it can never choose host or token.\nfunc (c *Client) Decrypt(ctx context.Context, blob []byte) ([]byte, error) {\n\tif !IsEnvelope(blob) {\n\t\treturn nil, errors.New(\"kms: unknown envelope format\")\n\t}\n\tif len(blob) > maxEnvelopeBytes {\n\t\treturn nil, errors.New(\"kms: envelope exceeds size limit\")\n\t}\n\tvar envelope Envelope\n\tif err := json.Unmarshal(blob[len(prefix):], &envelope); err != nil {\n\t\treturn nil, fmt.Errorf(\"kms: decode envelope: %w\", err)\n\t}\n\tif envelope.Provider != c.provider {\n\t\treturn nil, errors.New(\"kms: envelope provider does not match configured provider\")\n\t}\n\tif err := validateLocation(envelope.Region, envelope.KeyID); err != nil {\n\t\treturn nil, err\n\t}\n\tif envelope.Region != c.region {\n\t\treturn nil, errors.New(\"kms: envelope region is not approved\")\n\t}\n\tif _, ok := c.decryptKeyIDs[envelope.KeyID]; !ok {","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/shared/platform/kms/kms.go#L206-L242","documentation":"Error \"kms: unknown envelope format\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at shared/platform/kms/kms.go:224 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a known KMS envelope format."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}