Skip to content

fix: publish a connection password without a username - #1934

Open
ranjithguggilla wants to merge 2 commits into
tableau:developmentfrom
ranjithguggilla:fix/1926-credential-password-without-name
Open

ranjithguggilla wants to merge 2 commits into
tableau:developmentfrom
ranjithguggilla:fix/1926-credential-password-without-name

Conversation

@ranjithguggilla

@ranjithguggilla ranjithguggilla commented Nov 22, 2026 •

Copy link
Copy Markdown

Closes #1926

Motivation

Publishing a workbook with a connection password and no username is rejected by TSC, even though the REST API marks name and password on connectionCredentials as optional. Issue #1926 reports a publish against Tableau Server build main.26.1119.1559 (REST 3.31, a workbook with an extract and a SQL Server connection): omitting name kept the username already on the connection, and name="" cleared it. This pull request does not repeat that publish. tabcmd Classic does this with --db-password and no --db-username; tabcmd 2 uses TSC and drops the password.

Behavior change

ConnectionCredentials.name may be None. The request then omits the name attribute. A missing password still raises ValueError. An empty string is still sent as name="". The library does not document what a server does with either choice; the REST reference only marks both fields optional.

A ConnectionItem with a password and embed_password, and no username, is sent the same way. That is the case #1926 asks for: previously those two fields were set and the password was dropped with no error. A ConnectionItem with no password still sends no credentials element. Datasource and flow publish use the same builder.

Test plan

Workbook and datasource tests check a ConnectionCredentials with no name and a ConnectionItem with only a password. test_publish_connection_credentials_require_a_password checks the missing-password error. test_generate_xml_invalid_connection_credentials now expects that error only when the password is missing, and test_generate_xml_connection_credentials_without_a_name covers a missing name. The existing named-credential publish tests still pass.

Not covered: a publish against Tableau Server.

Tableau Server accepts connectionCredentials that carry a password and
no name, and then keeps the username already stored on the connection.
TSC refused that request, so a password-only publish never embedded the
password.
@jacalata

Copy link
Copy Markdown
Contributor

Thanks for this, @ranjithguggilla. The REST reference lists name and password in connectionCredentials as optional, so allowing name=None matches it. A few questions about the behavior and the docstring, once you've fixed the tests.

Question: callers who forgot the username (_add_connections_element)

elif connection.password is not None and connection.embed_password is not None: replaces a condition that also required username. A ConnectionItem with a password and embed_password but no username used to publish with no credentials element. It now sends a password-only one. The PR body documents this. Is it intended for callers who left the username out by mistake?

Question: datasource publish path

_add_credentials_element is also used by the datasource publish path. The body and tests cover workbooks only. Has a password-only datasource publish been tried against a server?

Question: docstring claims in connection_credentials.py

The docstring says "The server then keeps the username already stored on the connection" and that an empty string "clears it". The Publish Workbook reference says only that name and password are optional. It doesn't say either of these. The Motivation says you tested against Tableau Server (REST 3.31), but the Test plan says a publish against Tableau Server isn't covered. Could you say how the first claim was tested (server version, connection type)? Was the empty-string claim tested at all? If you can't link a source, could you soften the wording to say what was observed?

Drafted with AI assistance (Claude); reviewed and posted by Jac.

A connection with no name is valid, so the request-factory test that
expected an error for a missing name now expects that error only when
the password is missing. Datasource publish uses the same builder, and
its request is covered the same way as the workbook request.

The credential docstring no longer says what a server does with a
missing or empty name. The REST reference only marks both fields optional.
@ranjithguggilla

Copy link
Copy Markdown
Author

Addressed in e091752.

The Python tests failed in test_generate_xml_invalid_connection_credentials, which set name to None and expected ValueError. A missing name is valid now, so that test expects the error only when the password is missing. test_generate_xml_connection_credentials_without_a_name covers the name.

A ConnectionItem with a password and embed_password and no username is the case #1926 asks for. Those two fields used to be ignored and the password was dropped with no error. Setting both is a request to embed that password. A ConnectionItem with no password still sends no credentials element.

Datasource publish uses _add_credentials_element too. test_publish_connection_password_without_a_name in test/test_datasource.py checks the same XML as the workbook test. Neither publish was run against a server.

The docstring no longer says that omitting name keeps the username or that name="" clears it. Those are the results reported in #1926 (Tableau Server build main.26.1119.1559, REST 3.31, a workbook with an extract and a SQL Server connection), including the empty-string case. This pull request does not repeat that publish. The REST reference only marks name and password as optional.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publish: allow a connection credential with a password and no name

2 participants