api: deprecate UserItem.CSVImport.validate_file_for_import in favor of a safer replacement

未关闭
#1,847 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
python
领域
api

调研方向

Locate UserItem.CSVImport and its validate_file_for_import entry point, then inspect the samples/ callers and the existing _redact_password_column flow. Add the structured replacement and adapt the old method with its deprecation warning, ensuring the samples use the new method. Done means callers receive structured errors without raw field values while the legacy return shape remains available.

由索引模型根据 Issue 内容生成。

描述

validate_file_for_import is public API and its current shape invited the class of bug that #1829 patched. Proposing an additive replacement plus a deprecation on the existing method - no breaking change now, removal on the next major version.

Current signature:

def validate_file_for_import(csv_file, logger) -> tuple[int, list[str]]

Two problems with the shape:

  • Logger as a parameter made #1829 possible in the first place - a caller-supplied verbose logger could receive credential material. Prefer a module logger with documented levels.
  • Returning raw invalid lines forces callers to re-parse to give a useful error, and hands credential-bearing rows back to the caller (mitigated by _redact_password_column but the shape invites the bug).

Proposed replacement:

@dataclass(frozen=True)
class CsvImportError:
    row: int
    column: ColumnType | None
    reason: str  # never the raw field value

@dataclass
class CsvImportResult:
    valid_count: int
    errors: list[CsvImportError]

@staticmethod
def validate_import_file(csv_file) -> CsvImportResult: ...

Migration:

  1. Add validate_import_file returning the structured result.
  2. Reimplement validate_file_for_import as a thin wrapper that emits DeprecationWarning and adapts back to the old return shape.
  3. Update samples/ to use the new method.
  4. Remove the deprecated method on the next major version bump.

🤖 Generated with Claude Code

主要语言
Python
星标
716
派生
446
平均合并
8 天 8 小时
30 天内合并 PR
2

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

tableau/server-client-python 的其他 Issue

查看 tableau/server-client-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。