{"record":{"id":"a138f8e03948eb63","repo":"zylon-ai/private-gpt","slug":"invalid-system-value-value","errorCode":null,"errorMessage":"Invalid system value: {value}","messagePattern":"Invalid system value: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/chat/input_models.py","lineNumber":1264,"sourceCode":"            return [System.model_validate(value)]\n        if isinstance(value, list):\n            systems: list[System] = []\n            for item in value:\n                if isinstance(item, System):\n                    systems.append(item)\n                elif isinstance(item, TextBlock):\n                    systems.append(System(text=item.text))\n                elif isinstance(item, str):\n                    systems.append(System(text=item))\n                elif isinstance(item, dict):\n                    if item.get(\"type\") == \"text\" and isinstance(item.get(\"text\"), str):\n                        systems.append(System(text=item[\"text\"]))\n                    else:\n                        systems.append(System.model_validate(item))\n                else:\n                    raise ValueError(f\"Invalid system item: {item}\")\n            return systems or [System()]\n        raise ValueError(f\"Invalid system value: {value}\")\n\n    @field_validator(\"model\", mode=\"before\")\n    @classmethod\n    def normalize_model(cls, value: str | None) -> str:\n        if value is None:\n            return \"default\"\n        return value\n\n    @model_validator(mode=\"after\")\n    def extract_system_messages(self) -> \"MessagesInputBase\":\n        \"\"\"Extract role=system messages and append them to the system list.\"\"\"\n        system_msgs = [msg for msg in self.messages if msg.role == \"system\"]\n        if not system_msgs:\n            return self\n\n        self.messages = [msg for msg in self.messages if msg.role != \"system\"]\n\n        for msg in system_msgs:","sourceCodeStart":1246,"sourceCodeEnd":1282,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/chat/input_models.py#L1246-L1282","documentation":"Raised by GET /skills/{skill_id}/versions/{version} when the skill exists but SkillService.get_version() returns None — i.e. the version token does not resolve to a stored version of that skill. Distinct from the skill-level 404 in the same handler: here the parent exists but the version is gone or unknown.","triggerScenarios":"Using an expired/pruned version token; version deleted by another client; token copied from a different skill or environment.","commonSituations":"Version-retention policies pruning old versions while clients hold stale tokens; race between viewing and deleting a version.","solutions":["Re-list versions for the skill to get current tokens and pick the latest.","Handle 404 on version fetch gracefully by refreshing the version list.","Don't persist version tokens long-term; treat them as ephemeral cursors."],"exampleFix":"// before\nconst v = await skillsApi.getVersion(id, token, col);\n\n// after\nlet v;\ntry { v = await skillsApi.getVersion(id, token, col); }\ncatch (e) {\n  if (e.status !== 404) throw e;\n  const list = await skillsApi.listVersions(id, col);\n  v = list.data[0] ?? null; // fall back to newest version\n}","handlingStrategy":"fallback","validationCode":"const versions = await skillsApi.listVersions(id, collection);\nif (!versions.data.some((v) => v.version === token)) token = versions.data[0]?.version;","typeGuard":null,"tryCatchPattern":"try { return await skillsApi.getVersion(id, token, collection); }\ncatch (e) {\n  if (e.status === 404) { const l = await skillsApi.listVersions(id, collection); return l.data[0] ?? null; }\n  throw e;\n}","preventionTips":["Treat version tokens as ephemeral cursors, not durable references","Refresh the version list after any delete/version churn","Distinguish 'skill gone' vs 'version gone' by re-checking the skill"],"tags":["fastapi","http-404","skills","versioning","stale-token"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}