{"record":{"id":"117855ab630864d1","repo":"thanos-io/thanos","slug":"json-encode-no-downsample-mark","errorCode":null,"errorMessage":"json encode no downsample mark","messagePattern":"json encode no downsample mark","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/block.go","lineNumber":433,"sourceCode":"\tm := path.Join(id.String(), metadata.NoDownsampleMarkFilename)\n\tnoDownsampleMarkExists, err := bkt.Exists(ctx, m)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"check exists %s in bucket\", m)\n\t}\n\tif noDownsampleMarkExists {\n\t\tlevel.Warn(logger).Log(\"msg\", \"requested to mark for no deletion, but file already exists; this should not happen; investigate\", \"err\", errors.Errorf(\"file %s already exists in bucket\", m))\n\t\treturn nil\n\t}\n\tnoDownsampleMark, err := json.Marshal(metadata.NoDownsampleMark{\n\t\tID:      id,\n\t\tVersion: metadata.NoDownsampleMarkVersion1,\n\n\t\tNoDownsampleTime: time.Now().Unix(),\n\t\tReason:           reason,\n\t\tDetails:          details,\n\t})\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"json encode no downsample mark\")\n\t}\n\n\tif err := bkt.Upload(ctx, m, bytes.NewBuffer(noDownsampleMark)); err != nil {\n\t\treturn errors.Wrapf(err, \"upload file %s to bucket\", m)\n\t}\n\tmarkedForNoDownsample.Inc()\n\tlevel.Info(logger).Log(\"msg\", \"block has been marked for no downsample\", \"block\", id)\n\treturn nil\n}\n\n// RemoveMark removes the file which marked the block for deletion, no-downsample or no-compact.\nfunc RemoveMark(ctx context.Context, logger log.Logger, bkt objstore.Bucket, id ulid.ULID, removeMark prometheus.Counter, markedFilename string) error {\n\tmarkedFile := path.Join(id.String(), markedFilename)\n\tmarkedFileExists, err := bkt.Exists(ctx, markedFile)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"check if %s file exists in bucket\", markedFile)\n\t}\n\tif !markedFileExists {","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/block.go#L415-L451","documentation":"Wraps json.Marshal while serializing the NoDownsampleMark structure (block ULID, version, reason, details, timestamp) before uploading it to the bucket. Marshal of this fixed shape can only fail if a field cannot be represented — in practice an internal invariant break rather than user input.","triggerScenarios":"Thrown at pkg/block/block.go:433 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect metadata.NoDownsampleMark fields for serialization issues","Report with wrapped cause if reproducible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}