# 錯誤代碼說明-檔案管理類

### API 回應中的錯誤代碼

以下錯誤代碼會出現在同步 API 回應中，回應格式見 [例外狀況處理](https://privstation-docs.apmic.ai/latest/privai-400/例外狀況處理.md)。

| Error Code | HTTP Status | Scenario | Error Message | Inherent Payload |
| --- | --- | --- | --- | --- |
| `FILE_001` | 415 | 上傳的檔案格式不在支援清單中（支援格式見「上傳檔案」章節） | Unsupported media type. |  |
| `FILE_002` | 404 | 指定的 File 不存在、已被刪除，或不屬於目前的 API Key | File not found. |  |
| `FILE_003` | 409 | 上傳檔案時指定的 `id` 已存在 | File ID already exists. |  |
| `FILE_004` | 409 | 刪除的檔案仍被一個或多個 Fileset 使用 | File is used by filesets. | "fileset_ids": uuid[] |
| `FILE_007` | 404 | 指定品質的解析結果（parsed result）不存在，例如尚未解析或該品質未產生結果 | Parsed result not found. | "quality": "HQ" \| "LQ" \| "STD" |
| `FILE_008` | 404 | 指定品質的 chunks 不存在 | Chunks not found. | "quality": "HQ" \| "LQ" \| "STD" |
| `FILE_009` | 404 | 建立、更新或複製 Fileset 時，`file_ids` 中有部分檔案不存在 | Some Files are not found. | "file_ids": uuid[]（不存在的檔案） |
| `FILE_010` | 404 | Chat Completions 引用檔案內容時，該檔案指定品質的解析結果為空 | Parsed result is empty. | "quality": "HQ" \| "LQ" \| "STD" |

### 背景流程與保留錯誤代碼

以下錯誤代碼仍定義於 4.0.0，但不會出現在同步 API 回應中。背景流程失敗時，錯誤會以「錯誤類型名稱」記錄在檔案的 `metadata.fail_detail[].error_type`（見「例外狀況處理」章節），下表提供對照。

| Error Code | error_type | HTTP Status | Error Message | 說明 |
| --- | --- | --- | --- | --- |
| `FILE_010` | EmptyParsedResultError | 404 | Parsed result is empty. | 背景解析完成但沒有取得任何文字內容，檔案解析狀態會轉為 `failed` |
| `FILE_005` | FileParsingFailedError | 500 | Parsing error. | 保留代碼，4.0.0 不會產生 |
| `FILE_006` | FileSplittingFailedError | 500 | Splitting error. | 保留代碼，4.0.0 不會產生 |
| `FILE_011` | ParseConflictError | 409 | File is being parsed by another processor. | 已棄用，4.0.0 不會產生 |
| `FILE_012` | LQUnsupportedError | 400 | unsupported_in_lq_mode: {process_type} | 保留代碼，4.0.0 不會產生 |
