{"record":{"id":"1fd0fac3cd6498b6","repo":"sipeed/picoclaw","slug":"failed-to-load-mcp-config-schema-w","errorCode":null,"errorMessage":"failed to load MCP config schema: %w","messagePattern":"failed to load MCP config schema: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/mcp/helpers.go","lineNumber":156,"sourceCode":"\tfor name, server := range cfg.Tools.MCP.Servers {\n\t\tif server.Type != \"\" {\n\t\t\tserver.Type = config.NormalizeMCPTransportType(server.Type)\n\t\t}\n\t\tclone.Tools.MCP.Servers[name] = server\n\t}\n\n\treturn &clone\n}\n\nfunc validateConfigDocument(data []byte) error {\n\tvar instance map[string]any\n\tif err := json.Unmarshal(data, &instance); err != nil {\n\t\treturn fmt.Errorf(\"failed to decode serialized config: %w\", err)\n\t}\n\n\tschema, err := loadMCPConfigSchema()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to load MCP config schema: %w\", err)\n\t}\n\n\tif err := schema.Validate(instance); err != nil {\n\t\treturn fmt.Errorf(\"config validation failed: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc loadMCPConfigSchema() (*jsonschema.Resolved, error) {\n\tmcpConfigSchemaOnce.Do(func() {\n\t\tvar schema jsonschema.Schema\n\t\tif err := json.Unmarshal([]byte(mcpConfigSchemaJSON), &schema); err != nil {\n\t\t\terrMcpConfigSchema = err\n\t\t\treturn\n\t\t}\n\t\tmcpConfigSchema, errMcpConfigSchema = schema.Resolve(nil)\n\t})","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/mcp/helpers.go#L138-L174","documentation":"loadMCPConfigSchema parses the schema embedded in the binary (mcpConfigSchemaJSON constant) once via sync.Once (helpers.go:166-177). This error means the baked-in schema string is itself invalid JSON Schema — a build/source defect, not something user config or environment can cause. Every validated save passes through here.","triggerScenarios":"Editing mcpConfigSchemaJSON in helpers.go and introducing a JSON syntax error or an unresolvable $ref; a corrupted source tree producing a broken build.","commonSituations":"Contributors extending the config schema without running the package tests.","solutions":["Restore/fix the embedded schema constant in cmd/picoclaw/internal/mcp/helpers.go","Run the mcp package tests (go test ./cmd/picoclaw/...) after any schema change before building"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := saveCmd.Execute(); err != nil {\n\tif strings.Contains(err.Error(), \"failed to load MCP config schema\") {\n\t\t// schema is embedded in the binary — this indicates a broken build;\n\t\t// rebuild from a clean checkout rather than tweaking config\n\t\treturn fmt.Errorf(\"picoclaw build defect: embedded schema invalid: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["After modifying the embedded schema constant, run go test ./cmd/picoclaw/...","Build from a clean checkout when strange internal errors appear"],"tags":["go","json-schema","internal","build"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}