{"record":{"id":"ad26b3386302ed20","repo":"github/copilot-sdk","slug":"sessionfs-sessionstatepath-is-required-ad26b3","errorCode":null,"errorMessage":"SessionFS.SessionStatePath is required","messagePattern":"SessionFS\\.SessionStatePath is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/client.go","lineNumber":90,"sourceCode":"\t\tif providers[i].BearerTokenProvider != nil {\n\t\t\tcallbacks[providers[i].Name] = providers[i].BearerTokenProvider\n\t\t}\n\t}\n\tif len(callbacks) == 0 {\n\t\treturn nil\n\t}\n\treturn callbacks\n}\n\nfunc validateSessionFSConfig(config *SessionFSConfig) error {\n\tif config == nil {\n\t\treturn nil\n\t}\n\tif config.InitialWorkingDirectory == \"\" {\n\t\treturn errors.New(\"SessionFS.InitialWorkingDirectory is required\")\n\t}\n\tif config.SessionStatePath == \"\" {\n\t\treturn errors.New(\"SessionFS.SessionStatePath is required\")\n\t}\n\tif config.Conventions != rpc.SessionFSSetProviderConventionsPosix && config.Conventions != rpc.SessionFSSetProviderConventionsWindows {\n\t\treturn errors.New(\"SessionFS.Conventions must be either 'posix' or 'windows'\")\n\t}\n\treturn nil\n}\n\n// validateEnvironmentOptions enforces the transport-specific rules for\n// per-client environment, working directory, and telemetry. It panics (fails\n// loud) on a misconfiguration, matching the other SDKs.\n//\n// The in-process transport loads the native runtime into this process, whose\n// single environment block and process-global working directory cannot carry\n// per-client values, and whose telemetry lowers to shared process-global env\n// vars — so options that depend on them are rejected there. Child-process\n// transports each own their OS process, so per-connection env is allowed, but\n// setting it in both the client-level option and the connection is rejected.\nfunc validateEnvironmentOptions(connection RuntimeConnection, opts *ClientOptions) {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/client.go#L72-L108","documentation":"validateSessionFSConfig requires SessionFS.SessionStatePath to be a non-empty string when constructing a Client. The session state path is where the provider persists session state, so without it the SessionFS provider cannot be configured. NewClient fails fast with this error rather than starting with a half-configured filesystem session.","triggerScenarios":"Calling NewClient with a Config whose SessionFS is non-nil but has SessionStatePath set to \"\" (or left unset).","commonSituations":"Structuring the SessionFS config field-by-field and forgetting SessionStatePath; constructing Config dynamically from env/flags where the state-path variable is empty; copying a config struct and dropping one field.","solutions":["Set config.SessionFS.SessionStatePath to an absolute writable file path before calling NewClient","Derive it from an existing config value, e.g. filepath.Join(dir, \"session-state.json\")","Add a pre-construction validation step in your own code that asserts the path is non-empty"],"exampleFix":"// before\nclient, err := copilot.NewClient(cfg) // cfg.SessionFS.SessionStatePath == \"\"\n// after\ncfg.SessionFS.SessionStatePath = filepath.Join(dataDir, \"copilot-session-state.json\")\nclient, err := copilot.NewClient(cfg)","handlingStrategy":"validation","validationCode":"if cfg.SessionFS != nil && cfg.SessionFS.SessionStatePath == \"\" {\n    return fmt.Errorf(\"config error: SessionFS.SessionStatePath must be set\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set SessionStatePath to an absolute writable path when SessionFS is enabled","Centralize client config construction in one helper that fills defaults","Validate the full config before NewClient"],"tags":["go","configuration","sessionfs","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}