codeant-ai-for-open-source[bot] commented on code in PR #43583:
URL: https://github.com/apache/superset/pull/43583#discussion_r3870103554


##########
superset-frontend/src/components/Datasource/DatasourceModal/index.tsx:
##########
@@ -111,6 +113,23 @@ const DatasourceModal: 
FunctionComponent<DatasourceModalProps> = ({
   const [isEditing, setIsEditing] = useState<boolean>(false);
   const [modal, contextHolder] = Modal.useModal();
   const [confirmModalOpen, setConfirmModalOpen] = useState(false);
+
+  useEffect(() => {
+    setVersionEtag(etag);
+    if (etag || !show || !datasource.id) {
+      return;
+    }
+    SupersetClient.get({
+      endpoint: `/api/v1/dataset/${datasource.id}`,
+    })
+      .then(({ response }) => {
+        setVersionEtag(response.headers.get('ETag') ?? undefined);

Review Comment:
   **Suggestion:** The fallback GET retrieves only the ETag while the modal 
continues editing the caller-provided `datasource` snapshot. If that snapshot 
is stale, or if the user saves before this asynchronous GET resolves, the PUT 
can use a newer or missing validator and be accepted, allowing the stale 
full-object payload to overwrite newer changes. Seed the form and validator 
from the same response, or block saving until the validator request completes. 
[race condition]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Explore dataset editing can still silently overwrite changes from 
another tab.
   - ❌ Fast saves can bypass `If-Match` entirely.
   - ⚠️ Dataset List editing is protected by its same-response snapshot.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b2d782073fb9422cbe7f221ef5d49678&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=b2d782073fb9422cbe7f221ef5d49678&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/components/Datasource/DatasourceModal/index.tsx
   **Line:** 122:126
   **Comment:**
        *Race Condition: The fallback GET retrieves only the ETag while the 
modal continues editing the caller-provided `datasource` snapshot. If that 
snapshot is stale, or if the user saves before this asynchronous GET resolves, 
the PUT can use a newer or missing validator and be accepted, allowing the 
stale full-object payload to overwrite newer changes. Seed the form and 
validator from the same response, or block saving until the validator request 
completes.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43583&comment_hash=25aad9f15574dc124a98bc66d59a05a29ff45e08da37fd7191de7935bea06131&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43583&comment_hash=25aad9f15574dc124a98bc66d59a05a29ff45e08da37fd7191de7935bea06131&reaction=dislike'>👎</a>



##########
superset/datasets/api.py:
##########
@@ -626,6 +649,21 @@ def put(self, pk: int) -> Response:
         # ``ENABLE_VERSIONING_CAPTURE`` is off).
         old_info = current_entity_version_info(SqlaTable, pk)
 
+        try:
+            raise_for_stale_write(old_info.version_uuid)

Review Comment:
   **Suggestion:** The `If-Match` comparison is performed in a separate read 
from `UpdateDatasetCommand(...).run()`. Two concurrent PUT requests can both 
read the same `old_info.version_uuid`, both pass this check, and then commit 
sequentially, allowing the later full-object update to overwrite the earlier 
one. Make the validation and mutation atomic, for example by locking the 
dataset row or incorporating the expected version into the update condition and 
rejecting when no row is updated. [race condition]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Concurrent dataset PUTs can overwrite previously saved fields.
   - ❌ Optimistic-concurrency protection fails during overlapping saves.
   - ⚠️ Losing tabs receive success instead of conflict feedback.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=00e105e3a8c44c65a041cacf65a093cb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=00e105e3a8c44c65a041cacf65a093cb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/datasets/api.py
   **Line:** 653:653
   **Comment:**
        *Race Condition: The `If-Match` comparison is performed in a separate 
read from `UpdateDatasetCommand(...).run()`. Two concurrent PUT requests can 
both read the same `old_info.version_uuid`, both pass this check, and then 
commit sequentially, allowing the later full-object update to overwrite the 
earlier one. Make the validation and mutation atomic, for example by locking 
the dataset row or incorporating the expected version into the update condition 
and rejecting when no row is updated.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43583&comment_hash=4643dd313338f4f4c7b37c8496dbc03fc3b00eb92d6b243b27df17008ddca564&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43583&comment_hash=4643dd313338f4f4c7b37c8496dbc03fc3b00eb92d6b243b27df17008ddca564&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to