{"record":{"id":"fce44c8b76671a0b","repo":"micro/go-micro","slug":"unsupported-format","errorCode":null,"errorMessage":"unsupported format","messagePattern":"unsupported format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/reader/json/json.go","lineNumber":67,"sourceCode":"\t}\n\n\tcs := &source.ChangeSet{\n\t\tTimestamp: time.Now(),\n\t\tData:      b,\n\t\tSource:    \"json\",\n\t\tFormat:    j.json.String(),\n\t}\n\tcs.Checksum = cs.Sum()\n\n\treturn cs, nil\n}\n\nfunc (j *jsonReader) Values(ch *source.ChangeSet) (reader.Values, error) {\n\tif ch == nil {\n\t\treturn nil, errors.New(\"changeset is nil\")\n\t}\n\tif ch.Format != \"json\" {\n\t\treturn nil, errors.New(\"unsupported format\")\n\t}\n\treturn newValues(ch)\n}\n\nfunc (j *jsonReader) String() string {\n\treturn \"json\"\n}\n\n// NewReader creates a json reader.\nfunc NewReader(opts ...reader.Option) reader.Reader {\n\toptions := reader.NewOptions(opts...)\n\treturn &jsonReader{\n\t\tjson: json.NewEncoder(),\n\t\topts: options,\n\t}\n}\n","sourceCodeStart":49,"sourceCodeEnd":84,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/config/reader/json/json.go#L49-L84","documentation":"The JSON config reader only accepts changesets whose Format field is exactly \"json\". Values checks ch.Format != \"json\" and returns \"unsupported format\" otherwise. Each go-micro reader (json, yaml, etc.) handles only its own format, so a changeset produced by a different source format must be routed to the matching reader.","triggerScenarios":"Passing a *source.ChangeSet with Format \"yaml\", \"toml\", \"hcl\", or \"\" (unset) to jsonReader.Values — e.g. a YAML source's output fed into the JSON reader, or a custom source that forgot to set ChangeSet.Format.","commonSituations":"Loading a .yaml file but using the json reader in the config options; a custom source that returns a changeset without setting Format; changing a config file's format on disk without updating the reader codec selection.","solutions":["Ensure ChangeSet.Format is set to \"json\" for changesets passed to the json reader (fix the source if it leaves Format empty).","Use the reader matching the file format: yaml reader for YAML files, toml reader for TOML, etc.","Verify config source options (e.g. file.Extension / format option) match the actual file's format.","If you must accept multiple formats, dispatch on ch.Format to the appropriate reader instead of hardcoding json."],"exampleFix":"// before\n// yaml file loaded with json reader\nconf := json.New()\nv, _ := conf.Values(yamlChangeSet) // unsupported format\n// after\nconf := yaml.New()\nv, err := conf.Values(yamlChangeSet)","handlingStrategy":"validation","validationCode":"if cs == nil || cs.Format != \"json\" {\n    return fmt.Errorf(\"json reader requires Format=json, got %q\", cs.GetFormat())\n}\nvals, err := rdr.Values(cs)","typeGuard":"func isJSONChangeSet(ch *source.ChangeSet) bool { return ch != nil && ch.Format == \"json\" }","tryCatchPattern":null,"preventionTips":["Match the reader to the file format (json reader for .json, yaml reader for .yaml).","Ensure custom sources always set ChangeSet.Format.","Dispatch on Format when supporting multiple config formats.","Verify config source extension/format options after changing config files."],"tags":["config","reader","json","format","go"],"backgroundTag":"unsupported-format","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}