thanos-io/thanos · error

configuration file is not parsable

Error message

configuration file is not parsable

What it means

errParseConfigurationFile is a sentinel returned by loadConfig when ParseConfig cannot parse the hashring configuration file content. The config watcher reads the hashring file and parses it into []HashringConfig; any syntax or schema error in the file is wrapped with this sentinel so callers can detect parse failure via errors.Is. Receive cannot build a hashring until the file parses.

Solutions

  1. Validate the file with a JSON/YAML linter or `thanos tools bucket` style parse before deploying
  2. Check the wrapped %v detail in the error for the exact parse position
  3. Ensure the writer atomically replaces the file (write temp + rename) so the watcher never reads a half-written file
  4. Restore a known-good hashring config and redeploy

Example fix

// before (malformed)
[{"endpoints": [{"address": "recv-0:10901"}]
// after (valid)
[{"endpoints": [{"address": "recv-0:10901"}]}]
Defensive patterns

Strategy: validation

Validate before calling

// validate hashring JSON before deploying
var v []map[string]json.RawMessage
if err := json.Unmarshal(content, &v); err != nil {
	return fmt.Errorf("invalid hashring config: %w", err)
}

Try / catch

_, _, err := receive.ValidateConfig(logger, path)
if errors.Is(err, errParseConfigurationFile) {
	// reject deployment; fix file syntax
}

Prevention

When it happens

Trigger: loadConfig -> ParseConfig fails: invalid JSON/YAML syntax, unknown fields, or endpoint structures that do not unmarshal into Endpoint (before the empty check at config.go:402).

Common situations: Hand-edited hashring.json with a typo; config management tool writing a partial/truncated file; quoting or trailing-comma mistakes in the endpoints list.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/7f047de98c4ec9b2. Report an issue: GitHub.

Appendix: source

Thrown at pkg/receive/config.go:30

	"io"
	"os"
	"path/filepath"
	"strings"
	"time"

	"github.com/fsnotify/fsnotify"
	"github.com/go-kit/log"
	"github.com/go-kit/log/level"
	"github.com/pkg/errors"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/promauto"
	"github.com/prometheus/common/model"
	"github.com/prometheus/prometheus/model/labels"
)

var (
	// An errParseConfigurationFile is returned by the ConfigWatcher when parsing failed.
	errParseConfigurationFile = errors.New("configuration file is not parsable")
	// An errEmptyConfigurationFile is returned by the ConfigWatcher when attempting to load an empty configuration file.
	errEmptyConfigurationFile = errors.New("configuration file is empty")
)

type ReceiverMode string

const (
	RouterOnly     ReceiverMode = "RouterOnly"
	IngestorOnly   ReceiverMode = "IngestorOnly"
	RouterIngestor ReceiverMode = "RouterIngestor"

	DefaultCapNProtoPort string = "19391"
)

type endpoints []Endpoint

func (e endpoints) Len() int {
	return len(e)

View on GitHub (pinned to 35b8b99117)