{"record":{"id":"5a47d115978c68dc","repo":"xtekky/gpt4free","slug":"runtime-json-no-platforms-defined","errorCode":null,"errorMessage":"runtime.json: no platforms defined","messagePattern":"runtime\\.json: no platforms defined","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"g4f-go/download.go","lineNumber":480,"sourceCode":"\t}\n\texe, err := pythonExecutable(binDir)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif _, err := os.Stat(exe); err != nil {\n\t\treturn \"\", fmt.Errorf(\"python runtime extracted but %s is missing\", exe)\n\t}\n\treturn exe, nil\n}\n\n// parseRuntimeManifest decodes a RuntimeManifest from bytes.\nfunc parseRuntimeManifest(data []byte) (*RuntimeManifest, error) {\n\tvar m RuntimeManifest\n\tif err := json.Unmarshal(data, &m); err != nil {\n\t\treturn nil, err\n\t}\n\tif len(m.Platforms) == 0 {\n\t\treturn nil, fmt.Errorf(\"runtime.json: no platforms defined\")\n\t}\n\treturn &m, nil\n}\n","sourceCodeStart":462,"sourceCodeEnd":484,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f-go/download.go#L462-L484","documentation":"parseRuntimeManifest in g4f-go/download.go json.Unmarshals runtime.json and requires the Platforms map to be non-empty. An empty or missing 'platforms' object yields 'runtime.json: no platforms defined' — the manifest is structurally valid JSON but carries no runtime entries to install.","triggerScenarios":"Passing a runtime.json whose 'platforms' key is absent, null, or {} (a template file, a mistakenly stripped config, or a failed write that produced '{}').","commonSituations":"Hand-editing runtime.json and deleting entries; CI copying a placeholder manifest; a fetch of the manifest that returned an empty JSON object; key-name drift ('Platforms' vs 'platforms') in a differently-versioned file.","solutions":["Inspect runtime.json and confirm it has a populated lowercase 'platforms' object with per-OS/arch entries","Restore the manifest from the upstream repo instead of a locally stripped copy","Match the manifest schema to the Go struct (platforms -> map[string]RuntimeSpec with url/size/sha256)","If embedding the manifest, rebuild the binary after fixing the JSON"],"exampleFix":"// before\n// runtime.json: {\"version\": \"1.0\"}  -> no platforms defined\n\n// after\n// runtime.json\n{\n  \"platforms\": {\n    \"linux-x64\":  {\"url\": \"https://host/r-linux-x64.tar.gz\", \"size\": 29140615, \"sha256\": \"...\"},\n    \"darwin-arm64\": {\"url\": \"https://host/r-darwin-arm64.tar.gz\", \"size\": 1, \"sha256\": \"...\"}\n  }\n}","handlingStrategy":"validation","validationCode":"var m RuntimeManifest\nif err := json.Unmarshal(data, &m); err == nil && len(m.Platforms) == 0 {\n    // reject the manifest before install: no platforms to serve\n}","typeGuard":"func manifestHasPlatforms(m *RuntimeManifest) bool {\n    return m != nil && len(m.Platforms) > 0\n}","tryCatchPattern":"m, err := parseRuntimeManifest(data)\nif err != nil {\n    if strings.Contains(err.Error(), \"no platforms defined\") {\n        // fetch/restore the canonical runtime.json\n    }\n    return err\n}","preventionTips":["Lint runtime.json in CI: non-empty platforms, lowercase keys, url/size/sha256 present","Never hand-strip manifest entries without replacing the file","Rebuild binaries after embedding a fixed manifest"],"tags":["go","runtime-manifest","configuration","json"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}