{"record":{"id":"06021e756f6ae06c","repo":"portainer/portainer","slug":"unable-to-retrieve-environments-from-database-w","errorCode":null,"errorMessage":"unable to retrieve environments from database: %w","messagePattern":"unable to retrieve environments from database: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/internal/edge/edgestack.go","lineNumber":49,"sourceCode":"\t\t}\n\n\t\tedgeStackEndpoints = append(edgeStackEndpoints, EdgeGroupRelatedEndpoints(edgeGroup, endpoints, endpointGroups)...)\n\t}\n\n\treturn slicesx.Unique(edgeStackEndpoints), nil\n}\n\ntype EndpointRelationsConfig struct {\n\tEndpoints      []portainer.Endpoint\n\tEndpointGroups []portainer.EndpointGroup\n\tEdgeGroups     []portainer.EdgeGroup\n}\n\n// FetchEndpointRelationsConfig fetches config needed for Edge Stack related endpoints\nfunc FetchEndpointRelationsConfig(tx dataservices.DataStoreTx) (*EndpointRelationsConfig, error) {\n\tendpoints, err := tx.Endpoint().Endpoints()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to retrieve environments from database: %w\", err)\n\t}\n\n\tendpointGroups, err := tx.EndpointGroup().ReadAll()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to retrieve environment groups from database: %w\", err)\n\t}\n\n\tedgeGroups, err := tx.EdgeGroup().ReadAll()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to retrieve edge groups from database: %w\", err)\n\t}\n\n\treturn &EndpointRelationsConfig{\n\t\tEndpoints:      endpoints,\n\t\tEndpointGroups: endpointGroups,\n\t\tEdgeGroups:     edgeGroups,\n\t}, nil\n}","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/portainer/portainer/blob/17e74456ff6e794b9d5439ec3fa06922aa18a3f8/api/internal/edge/edgestack.go#L31-L67","documentation":"Error \"unable to retrieve environments from database: %w\" thrown in portainer/portainer.","triggerScenarios":"Thrown at api/internal/edge/edgestack.go:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"17e74456ff6e794b9d5439ec3fa06922aa18a3f8","analyzedAt":"2026-08-26T23:09:01.915Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}