{"record":{"id":"4f066a57b4253481","repo":"semaphoreui/semaphore","slug":"values-not-loaded","errorCode":null,"errorMessage":"values not loaded","messagePattern":"values not loaded","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/export/Exporter.go","lineNumber":206,"sourceCode":"}\n\ntype ValueExporter[T EntityType] interface {\n\trestoreValue(val EntityObject[T], store db.Store, exporter DataExporter) (err error)\n\n\tgetName() string\n}\n\ntype ValueMap[T EntityType] struct {\n\tvalues      []EntityObject[T]\n\tkeyScopeMap map[string]bool\n\terrs        []string\n\tuniqueKeys  bool\n}\n\nfunc (t *ValueMap[T]) getLoadedKeys(scope string) ([]EntityKey, error) {\n\n\tif t.values == nil {\n\t\treturn nil, fmt.Errorf(\"values not loaded\")\n\t}\n\n\tkeys := make([]EntityKey, 0, len(t.values))\n\tfor _, v := range t.values {\n\t\tif v.scope == scope {\n\t\t\tkeys = append(keys, v.value.GetDbKey())\n\t\t}\n\t}\n\n\treturn keys, nil\n}\n\nfunc (t *ValueMap[T]) getLoadedKeysInt(scope string) ([]int, error) {\n\tkeys, err := t.getLoadedKeys(scope)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tkeysInt := make([]int, 0)","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/services/export/Exporter.go#L188-L224","documentation":"ValueMap.getLoadedKeys requires the entity values to have been loaded from the store beforehand; if the internal values slice is still nil, the exporter was used before its load phase. The error prevents computing keys from non-existent data.","triggerScenarios":"Calling getLoadedKeys (via getLoadedKeysInt) on a ValueMap whose load() was never invoked — e.g. the export/import chain asks for loaded keys of a type before running that type's loader, or loading was skipped due to an earlier failure.","commonSituations":"Customizing the export chain and calling getLoadedKeys out of order; an earlier load error left the exporter uninitialized while dependent exporters still query it.","solutions":["Ensure exporter.load(store, chain, progress) runs for every type before any getLoadedKeys call on it","Check for and handle earlier load errors that left the ValueMap uninitialized","If writing custom exporter code, call the load step explicitly before resolving keys"],"exampleFix":"// before\nkeys, err := valueMap.getLoadedKeys(scope) // 'values not loaded'\n// after\nif err := valueMap.load(store, chain, progress); err != nil {\n    return err\n}\nkeys, err := valueMap.getLoadedKeys(scope)","handlingStrategy":"try-catch","validationCode":"if valueMap.values == nil {\n    return errors.New(\"load values before reading keys\")\n}","typeGuard":null,"tryCatchPattern":"keys, err := valueMap.getLoadedKeys(scope)\nif err != nil && err.Error() == \"values not loaded\" {\n    if lerr := valueMap.load(store, chain, progress); lerr != nil {\n        return lerr\n    }\n    keys, err = valueMap.getLoadedKeys(scope)\n}\nif err != nil { return err }","preventionTips":["Respect the load-before-query ordering of the exporter chain","Handle earlier load failures so the chain is never partially initialized","Write integration tests that exercise the full export order"],"tags":["go","export","import","initialization-order"],"backgroundTag":"invalid-state-transition","analyzedSha":"1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa","analyzedAt":"2026-09-07T11:00:33.293Z","contentChangedAt":"2026-09-07T11:00:33.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}