Skip to content

Commit 4b9eb47

Browse files
jacalataclaude
andcommitted
Use ValueError on 'too many columns'; drop stale enum-guard test
Two small fixes tied together: - `_validate_import_line_or_throw` raised AttributeError on the too-many-columns branch; `create_user_from_line` uses ValueError for the same condition. Copilot review flagged the inconsistency in #1811 since callers using `_validate_import_line_or_throw` directly have to catch a different exception than they would from `create_user_from_line` for the same malformed input. Use ValueError throughout for input-shape violations. - `test_set_values_rejects_invalid_auth_setting` asserted _set_values raises ValueError on an unknown auth string. That's exactly the behavior b088d3d removed (server-parse paths must accept unknown future auth values). b088d3d added the positive test (`test_from_xml_accepts_unknown_auth_setting` in test_user.py) but forgot to delete the contradictory one. Drop it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5042949 commit 4b9eb47

2 files changed

Lines changed: 1 addition & 9 deletions

File tree

tableauserverclient/models/user_item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def _validate_import_line_or_throw(incoming, logger) -> None:
539539

540540
line = list(map(str.strip, incoming.split(",")))
541541
if len(line) > UserItem.CSVImport.COLUMN_COUNT:
542-
raise AttributeError("Too many attributes in line")
542+
raise ValueError("Too many attributes for user import")
543543
username = line[UserItem.CSVImport.ColumnType.USERNAME.value]
544544
logger.debug(f"> details - {username}")
545545
UserItem.validate_username_or_throw(username)

test/test_user_model.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,3 @@ def test_create_user_with_lowercase_auth_accepted() -> None:
183183
user = TSC.UserItem.CSVImport.create_user_from_line("username, pword, fname, creator, none, yes, email, saml")
184184
assert user is not None
185185
assert user.auth_setting == "SAML"
186-
187-
188-
def test_set_values_rejects_invalid_auth_setting() -> None:
189-
# _set_values must route auth_setting through the @property_is_enum guard.
190-
# Attempting to set an invalid auth string must raise, not silently succeed.
191-
user = TSC.UserItem("someone")
192-
with pytest.raises(ValueError):
193-
user._set_values(None, None, None, None, None, None, None, "NotAnAuthType", None, None, None, None)

0 commit comments

Comments
 (0)