{"record":{"id":"657c952d33e5341e","repo":"glanceapp/glance","slug":"subrequest-with-key-q-has-not-been-defined","errorCode":null,"errorMessage":"subrequest with key %q has not been defined","messagePattern":"subrequest with key %q has not been defined","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-custom-api.go","lineNumber":225,"sourceCode":"\tresult := make([]decoratedGJSONResult, 0, 5)\n\n\tgjson.ForEachLine(data.JSON.Raw, func(line gjson.Result) bool {\n\t\tresult = append(result, decoratedGJSONResult{line})\n\t\treturn true\n\t})\n\n\treturn result\n}\n\nfunc (data *customAPITemplateData) Subrequest(key string) *customAPIResponseData {\n\treq, exists := data.subrequests[key]\n\tif !exists {\n\t\t// We have to panic here since there's nothing sensible we can return and the\n\t\t// lack of an error would cause requested data to return zero values which\n\t\t// would be confusing from the user's perspective. Go's template module\n\t\t// handles recovering from panics and will return the panic message as an\n\t\t// error during template execution.\n\t\tpanic(fmt.Sprintf(\"subrequest with key %q has not been defined\", key))\n\t}\n\n\treturn req\n}\n\nfunc fetchCustomAPIResponse(ctx context.Context, req *CustomAPIRequest) (*customAPIResponseData, error) {\n\tif req == nil || req.URL == \"\" {\n\t\treturn &customAPIResponseData{\n\t\t\tJSON:     decoratedGJSONResult{gjson.Result{}},\n\t\t\tResponse: &http.Response{},\n\t\t}, nil\n\t}\n\n\tif req.bodyReader != nil {\n\t\treq.bodyReader.Seek(0, io.SeekStart)\n\t}\n\n\tclient := ternary(req.AllowInsecure, defaultInsecureHTTPClient, defaultHTTPClient)","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-custom-api.go#L207-L243","documentation":"Error \"subrequest with key %q has not been defined\" thrown in glanceapp/glance.","triggerScenarios":"Raised when the template references a subrequest key that was never declared in the widget's subrequests configuration.","commonSituations":"Renaming or removing a subrequest without updating the template, or a typo in the subrequest key used in the template.","solutions":["Define the subrequest with the same key under the widget's 'subrequests' section before referencing it with .Subrequest in the template.","Check for typos in the subrequest key used in the template versus the key defined in the configuration."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}