{"record":{"id":"e5a110a8916314e1","repo":"tinyhumansai/openhuman","slug":"rpc-envelope-contains-undefined-data","errorCode":null,"errorMessage":"RPC envelope contains undefined data","messagePattern":"RPC envelope contains undefined data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/services/api/agentProfilesApi.ts","lineNumber":12,"sourceCode":"import type { AgentProfile, AgentProfilesResponse } from '../../types/agentProfile';\nimport { callCoreRpc } from '../coreRpcClient';\n\ninterface Envelope<T> {\n  data?: T;\n}\n\nfunction unwrapEnvelope<T>(response: Envelope<T> | T): T {\n  if (response && typeof response === 'object' && 'data' in response) {\n    const envelope = response as Envelope<T>;\n    if (envelope.data === undefined) {\n      throw new Error('RPC envelope contains undefined data');\n    }\n    return envelope.data;\n  }\n  return response as T;\n}\n\nexport const agentProfilesApi = {\n  list: async (): Promise<AgentProfilesResponse> => {\n    const response = await callCoreRpc<Envelope<AgentProfilesResponse>>({\n      method: 'openhuman.profiles_list',\n    });\n    return unwrapEnvelope(response);\n  },\n\n  select: async (profileId: string): Promise<AgentProfilesResponse> => {\n    const response = await callCoreRpc<Envelope<AgentProfilesResponse>>({\n      method: 'openhuman.profiles_select',\n      params: { profile_id: profileId },","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/app/src/services/api/agentProfilesApi.ts#L1-L30","documentation":"Startup error from `openhuman subconscious tick`: `Config::load_or_init()` failed and the underlying error is appended verbatim after the colon. load_or_init reads (or creates) the workspace config and applies OPENHUMAN_* env overrides, so the appended cause is typically a TOML parse error with file/line, a filesystem/permission error on the workspace dir, or an invalid env-override value. The wrapper uses map_err with display formatting, so the original error chain is flattened into the message text.","triggerScenarios":"Hand-edited config.toml with broken quoting/syntax (cause shows the line); workspace directory (default ~/.openhuman, or your --workspace) unwritable — read-only volume, wrong owner, disk full; a malformed OPENHUMAN_* env override that fails schema parsing; partial/corrupt write from a crash during config migration.","commonSituations":"First run inside a container with no writable HOME; editing config with an editor that changed quoting; a version upgrade that partially migrated config schema; --workspace pointing at a path that cannot be created.","solutions":["Read the text after 'config load failed:' — it names the actual cause and, for TOML errors, the file and line to fix","Check the workspace dir is readable+writable by the process user (default ~/.openhuman; or the path passed via --workspace / OPENHUMAN_WORKSPACE)","Validate the config file parses as TOML before retrying (e.g. `python3 -c \"import tomllib,sys; tomllib.load(open(sys.argv[1],'rb'))\" <file>`)","Bisect a corrupt workspace from an environment problem: `openhuman subconscious tick --workspace /tmp/fresh-ws`"],"exampleFix":"# before: config load failed: expected equals, found newline at line 12\n#   (broken hand edit in the workspace config.toml)\n# after: fix line 12 quoting, or start clean:\nopenhuman subconscious tick --workspace /tmp/fresh-ws","handlingStrategy":"try-catch","validationCode":"# bash: pre-flight the workspace before ticking\nws=\"${OPENHUMAN_WORKSPACE:-$HOME/.openhuman}\"\n[ -d \"$ws\" ] || mkdir -p \"$ws\" 2>/dev/null || { echo \"workspace not writable: $ws\" >&2; exit 2; }\n[ -w \"$ws\" ] || { echo \"workspace not writable: $ws\" >&2; exit 2; }\ncfg=$(find \"$ws\" -maxdepth 2 -name '*.toml' | head -1)\n[ -z \"$cfg\" ] || python3 -c \"import tomllib,sys; tomllib.load(open(sys.argv[1],'rb'))\" \"$cfg\" 2>/dev/null || { echo \"config TOML invalid: $cfg\" >&2; exit 2; }","typeGuard":null,"tryCatchPattern":"# Rust caller: the anyhow context flattens the chain, so match on the message prefix\nmatch run_subconscious_command(&args) {\n    Err(e) if e.to_string().starts_with(\"config load failed:\") => {\n        eprintln!(\"config/workspace problem — fix the cause after the colon, or tick a fresh --workspace\");\n        std::process::exit(78); // EX_CONFIG\n    }\n    other => other,\n}","preventionTips":["Treat the text after 'config load failed:' as the real diagnosis — it carries the underlying IO/TOML error verbatim","Keep workspace dirs writable by the service user; in containers set HOME or OPENHUMAN_WORKSPACE to a writable volume","Validate config edits with a TOML parser before restarting the daemon","Use a scratch --workspace to bisect corrupt-config vs environment failures"],"tags":["configuration","toml","filesystem","startup","subconscious"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}