Skip to content

Commit 0f5cc43

Browse files
committed
Update datasources_endpoint.py
require project id for updating datasource before 3.15 for #1072
1 parent ad78db4 commit 0f5cc43

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
@@ -136,11 +136,20 @@ def update(self, datasource_item: DatasourceItem) -> DatasourceItem:
136136
if not datasource_item.id:
137137
error = "Datasource item missing ID. Datasource must be retrieved from server first."
138138
raise MissingRequiredFieldError(error)
139+
# bug - before v3.15 you must always include the project id
140+
if datasource_item.owner_id and not datasource_item.project_id:
141+
if not self.parent_srv.check_at_least_version(self, "3.15"):
142+
error = (
143+
"Attempting to set new owner but datasource is missing Project ID."
144+
"In versions before 3.15 the project id must be included to update the owner."
145+
)
146+
raise MissingRequiredFieldError(error)
139147

140148
self._resource_tagger.update_tags(self.baseurl, datasource_item)
141149

142150
# Update the datasource itself
143151
url = "{0}/{1}".format(self.baseurl, datasource_item.id)
152+
144153
update_req = RequestFactory.Datasource.update_req(datasource_item)
145154
server_response = self.put_request(url, update_req)
146155
logger.info("Updated datasource item (ID: {0})".format(datasource_item.id))

0 commit comments

Comments
 (0)