Skip to content

Commit 83c216e

Browse files
authored
Fix bug in update-datasources before 3.15 (#1203)
require project id for updating datasource before 3.15 for #1072
1 parent c7d0ba5 commit 83c216e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tableauserverclient/server/endpoint/datasources_endpoint.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,20 @@ def update(self, datasource_item: DatasourceItem) -> DatasourceItem:
140140
if not datasource_item.id:
141141
error = "Datasource item missing ID. Datasource must be retrieved from server first."
142142
raise MissingRequiredFieldError(error)
143+
# bug - before v3.15 you must always include the project id
144+
if datasource_item.owner_id and not datasource_item.project_id:
145+
if not self.parent_srv.check_at_least_version("3.15"):
146+
error = (
147+
"Attempting to set new owner but datasource is missing Project ID."
148+
"In versions before 3.15 the project id must be included to update the owner."
149+
)
150+
raise MissingRequiredFieldError(error)
143151

144152
self._resource_tagger.update_tags(self.baseurl, datasource_item)
145153

146154
# Update the datasource itself
147155
url = "{0}/{1}".format(self.baseurl, datasource_item.id)
156+
148157
update_req = RequestFactory.Datasource.update_req(datasource_item)
149158
server_response = self.put_request(url, update_req)
150159
logger.info("Updated datasource item (ID: {0})".format(datasource_item.id))

0 commit comments

Comments
 (0)