Skip to content

[Bug] leetcode.cn: translatedName null causes API response validation failure #24

Description

@sanbei101

问题描述

使用leetcode.cn时,show 和 pick 命令在某些题目上会报 API 响应验证错误。原因是 CLI 的 Zod 验证器要求 translatedName 字段必须是 string 类型,但 leetcode.cn 对于没有中文翻译的标签会返回 null,导致验证失败。
这个问题似乎在蛮多题目上存在的

$ leetcode p 22
✖ Failed to fetch problem
API Response Validation Failed

$ leetcode p 23
✖ Failed to fetch problem
API Response Validation Failed

$ leetcode p 24
✔ Created 24.swap-nodes-in-pairs.py
Path: [project_path]/solve/Medium/24.swap-nodes-in-pairs.py

$ leetcode show 22
✖ Failed to fetch problem
[
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "question",
      "topicTags",
      3,
      "translatedName"
    ],
    "message": "Invalid input: expected string, received null"
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions