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

Aperta
#1,847 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
api

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Python
Stelle
716
Fork
446
Merge medio
8g 8h
PR unite (30g)
2

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tableau/server-client-python

Tutte le issue di tableau/server-client-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.