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

Open
#1,847 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
api

Research direction

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.

Written by the indexing model from the issue text.

Description

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

Dominant language
Python
Stars
716
Forks
446
Avg merge
8d 8h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tableau/server-client-python

All issues in tableau/server-client-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.