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


##########
superset/views/users/api.py:
##########
@@ -14,47 +14,163 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+from __future__ import annotations
+
+import functools
+import logging
 from datetime import datetime
-from typing import Any, Dict
+from typing import Any, Callable, Dict
 
-from flask import current_app as app, g, redirect, request, Response
+from flask import current_app as app, g, redirect, request, Response, session
 from flask_appbuilder.api import expose, permission_name, safe
+from flask_appbuilder.const import AUTH_DB
 from flask_appbuilder.security.decorators import protect
 from flask_appbuilder.security.sqla.models import User
+from flask_login import login_user
 from marshmallow import ValidationError
+from sqlalchemy.exc import SQLAlchemyError
 from sqlalchemy.orm.exc import NoResultFound
-from werkzeug.security import generate_password_hash
 
 from superset import is_feature_enabled
 from superset.daos.user import UserDAO
-from superset.extensions import db, event_logger
+from superset.extensions import db, event_logger, security_manager
+from superset.utils.auth_db_password import (
+    get_auth_db_login_rate_limit_string,
+    get_public_auth_db_password_policy,
+    validate_auth_db_password,
+)
+from superset.utils.auth_db_password_hash import (
+    hash_auth_db_password,
+    verify_auth_db_password,
+)
+from superset.utils.auth_session_stamp import (
+    bump_user_session_auth_stamp,
+    clear_flask_login_remember_cookie,
+)
 from superset.utils.slack import get_user_avatar, SlackClientError
 from superset.views.base_api import BaseSupersetApi, requires_json, 
statsd_metrics
-from superset.views.users.schemas import CurrentUserPutSchema, 
UserResponseSchema
+from superset.views.users.schemas import (
+    CurrentUserPasswordPutSchema,
+    CurrentUserPutSchema,
+    UserResponseSchema,
+)
 from superset.views.utils import bootstrap_user_data
 
+logger = logging.getLogger(__name__)
+
 user_response_schema = UserResponseSchema()
 
 
+def _get_client_ip() -> str | None:
+    """Return best-effort client IP from request context."""
+    if request.access_route:
+        return request.access_route[0]
+    return request.remote_addr
+
+
+def _me_password_rate_limit_key() -> str:
+    uid = getattr(getattr(g, "user", None), "id", None)
+    if uid is not None:
+        return f"me_password_uid:{uid}"
+    return _get_client_ip() or "unknown"
+
+
+def _rate_limit_me_password_change(
+    f: Callable[..., Response],
+) -> Callable[..., Response]:
+    """Apply AUTH_DB ``login_rate_limit`` when Flask-Limiter is enabled."""
+
+    @functools.wraps(f)
+    def wrapped(self: CurrentUserRestApi, *args: Any, **kwargs: Any) -> 
Response:
+        """Invoke ``f`` directly or through Flask-Limiter when rate limiting 
is on."""
+        if not app.config.get("RATELIMIT_ENABLED", False):
+            return f(self, *args, **kwargs)
+        limiter = getattr(security_manager, "limiter", None)
+        if limiter is None:
+            return f(self, *args, **kwargs)
+        limited_view = limiter.limit(
+            get_auth_db_login_rate_limit_string(),
+            key_func=_me_password_rate_limit_key,
+            methods=["PUT"],
+        )(f)
+        return limited_view(self, *args, **kwargs)
+
+    return wrapped
+
+
+class PasswordChangeConflictError(Exception):
+    """Raised when an optimistic password update loses a concurrent write 
race."""
+
+
+def _load_password_change_body(
+    schema: CurrentUserPasswordPutSchema,
+    payload: object,
+) -> dict[str, str]:
+    """Parse and policy-validate a password-change request payload."""
+    body = schema.load(payload or {})
+    validate_auth_db_password(body["new_password"])
+    return body
+
+
+def _commit_user_password_change(
+    api: CurrentUserRestApi,
+    user_id: int,
+    old_hash: str,
+    new_hash: str,
+) -> User:
+    """Persist a password change and rotate the user's session auth stamp."""
+    api.pre_update(g.user, {})
+    rows_updated = (
+        db.session.query(User)
+        .filter(User.id == user_id, User.password == old_hash)
+        .update(
+            {
+                User.password: new_hash,
+                User.changed_on: g.user.changed_on,
+                User.changed_by_fk: g.user.changed_by_fk,
+            },
+            synchronize_session=False,
+        )
+    )
+    if rows_updated != 1:
+        db.session.rollback()  # pylint: disable=consider-using-transaction
+        raise PasswordChangeConflictError
+
+    bump_user_session_auth_stamp(user_id)
+    db.session.commit()  # pylint: disable=consider-using-transaction
+    user_after = db.session.get(User, user_id)
+    if user_after is None:
+        logger.error("User missing after password commit for id=%s", user_id)
+        raise SQLAlchemyError("user missing after password commit")

Review Comment:
   **Suggestion:** The password update and session-stamp rotation are not 
committed atomically: `bump_user_session_auth_stamp()` is transaction-decorated 
and can commit early, but this function can still raise afterward (for example 
when `user_after` is missing), which makes the API return an error after the 
password was already changed. Keep the whole password-change flow in one 
transaction and commit once at the end so failure paths cannot report 500 after 
a successful password write. [race condition]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ /api/v1/me/password can 500 after persisting change.
   - ⚠️ Users may retry thinking prior password change failed.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Log in with AUTH_DB enabled and call `PUT /api/v1/me/password`, handled by
   `CurrentUserRestApi.update_my_password` in 
`superset/views/users/api.py:36-125`, which
   after basic validation calls `_commit_user_password_change` at
   `superset/views/users/api.py:115-145`.
   
   2. Inside `_commit_user_password_change`, the code updates `User.password` 
via
   `db.session.query(User)...update(...)` and, if one row was updated, calls
   `bump_user_session_auth_stamp(user_id)` at `superset/views/users/api.py:139` 
before any
   explicit commit.
   
   3. `bump_user_session_auth_stamp` in 
`superset/utils/auth_session_stamp.py:99-121` is
   decorated with `@transaction()` from `superset/utils/decorators.py:16-56`, 
which sets
   `g.in_transaction`, executes the function, and then calls 
`db.session.commit()` on
   success; this commit includes the earlier `User.password` update made in
   `_commit_user_password_change`.
   
   4. After `bump_user_session_auth_stamp` returns, 
`_commit_user_password_change` runs
   `user_after = db.session.get(User, user_id)` and raises `SQLAlchemyError` if 
it returns
   `None` (`superset/views/users/api.py:141-144`); in a test or 
concurrent-delete scenario
   (e.g. monkeypatching `db.session.get` to raise or return `None`), the API 
returns a 500
   via the `except SQLAlchemyError` block in `update_my_password`
   (`superset/views/users/api.py:103-121`) even though the password (and 
session stamp) have
   already been committed by the `@transaction` decorator.
   ```
   </details>
   
   [![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=d69b98689a014cc6a6d540bdc1949d8f&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=d69b98689a014cc6a6d540bdc1949d8f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/views/users/api.py
   **Line:** 139:144
   **Comment:**
        *Race Condition: The password update and session-stamp rotation are not 
committed atomically: `bump_user_session_auth_stamp()` is transaction-decorated 
and can commit early, but this function can still raise afterward (for example 
when `user_after` is missing), which makes the API return an error after the 
password was already changed. Keep the whole password-change flow in one 
transaction and commit once at the end so failure paths cannot report 500 after 
a successful password write.
   
   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%2F39469&comment_hash=ac89afd0a7ce843cae7c321cf52d979aba8752193bb7176cbbdc3383bdf87d10&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39469&comment_hash=ac89afd0a7ce843cae7c321cf52d979aba8752193bb7176cbbdc3383bdf87d10&reaction=dislike'>👎</a>



##########
superset/views/users/schemas.py:
##########
@@ -51,8 +51,33 @@ class CurrentUserPutSchema(Schema):
         metadata={"description": last_name_description},
         validate=[Length(1, 64)],
     )
-    password = fields.String(
-        required=False,
-        validate=[PasswordComplexityValidator()],
-        metadata={"description": password_description},
+
+
+class CurrentUserPasswordPutSchema(Schema):
+    """Payload for ``PUT /api/v1/me/password`` (AUTH_DB only)."""
+
+    current_password = fields.String(
+        required=True,
+        metadata={"description": current_password_description},
+        validate=[Length(min=1, max=256)],
     )
+    new_password = fields.String(
+        required=True,
+        metadata={"description": new_password_description},
+        validate=[Length(min=1, max=256)],
+    )

Review Comment:
   **Suggestion:** The schema hard-codes `new_password` to `Length(min=1, 
...)`, which conflicts with the configurable password policy (the policy layer 
explicitly supports `password_min_length = 0`). This creates an API contract 
mismatch where a password accepted by configured policy can still be rejected 
at schema validation. Align schema constraints with policy enforcement (or 
remove the hardcoded min for `new_password`). [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ /api/v1/me/password may reject policy-compliant passwords.
   - ⚠️ Frontend policy UI disagrees with backend request schema.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure `AUTH_DB_CONFIG` so that `password_min_length` is set to `0` 
(or any value
   below `1`), which is merged into the effective policy by 
`get_merged_auth_db_config` in
   `superset/utils/auth_db_password.py:100-103` and used by 
`validate_auth_db_password` at
   `superset/utils/auth_db_password.py:160-173`.
   
   2. With `AUTH_TYPE` set to `AUTH_DB`, authenticate as a user and send `PUT
   /api/v1/me/password` (handled by `CurrentUserRestApi.update_my_password` in
   `superset/views/users/api.py:36-125`) with JSON like `{"current_password": 
"...",
   "new_password": "", "confirm_password": ""}`.
   
   3. `update_my_password` calls `_load_password_change_body`
   (`superset/views/users/api.py:105-112`), which in turn calls
   `CurrentUserPasswordPutSchema.load()`; that schema in
   `superset/views/users/schemas.py:56-73` defines `new_password = 
fields.String(...,
   validate=[Length(min=1, max=256)])`, so marshmallow raises a 
`ValidationError` for
   `new_password` being shorter than 1 character, and `update_my_password` 
returns a 400 from
   its `except ValidationError` block at `superset/views/users/api.py:86-101`.
   
   4. If `validate_auth_db_password` is invoked directly with the same 
empty-string password
   under `password_min_length = 0`, it will accept the value (no length error at
   `superset/utils/auth_db_password.py:171-173`), demonstrating a real mismatch 
between
   schema-level request validation and the configurable AUTH_DB password policy 
that the
   endpoint's own docstring claims to enforce.
   ```
   </details>
   
   [![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=90b34de843104094b636364e0723cb1e&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=90b34de843104094b636364e0723cb1e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/views/users/schemas.py
   **Line:** 64:68
   **Comment:**
        *Api Mismatch: The schema hard-codes `new_password` to `Length(min=1, 
...)`, which conflicts with the configurable password policy (the policy layer 
explicitly supports `password_min_length = 0`). This creates an API contract 
mismatch where a password accepted by configured policy can still be rejected 
at schema validation. Align schema constraints with policy enforcement (or 
remove the hardcoded min for `new_password`).
   
   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%2F39469&comment_hash=987a268a0497f7086091814bb0d8976c1c8e9067b8fb49cf505d9abf733b5743&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39469&comment_hash=987a268a0497f7086091814bb0d8976c1c8e9067b8fb49cf505d9abf733b5743&reaction=dislike'>👎</a>



##########
superset-frontend/src/constants/auth.ts:
##########
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/** Mirrors Flask-AppBuilder ``AUTH_TYPE`` values from bootstrap 
``common.conf``. */
+export enum AuthType {
+  AuthOID = 0,
+  AuthDB = 1,
+  AuthLDAP = 2,
+  AuthOauth = 4,
+  AuthSAML = 5,

Review Comment:
   **Suggestion:** This enum claims to mirror Flask-AppBuilder `AUTH_TYPE` 
values, but it omits the valid `AUTH_REMOTE_USER` value (`3`). That creates an 
incomplete contract for consumers of `AuthType` and can cause wrong branching 
or impossible-type assumptions when bootstrap data contains that auth mode. Add 
the missing enum member so frontend auth-mode checks stay aligned with backend 
constants. [incomplete implementation]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Frontend cannot type-safely represent AUTH_REMOTE_USER mode.
   - ⚠️ Future auth-mode switches risk mishandling remote-user configuration.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. In the backend config at `superset/config.py:432-437`, note that comments 
describe
   `AUTH_DB`, `AUTH_LDAP`, and `AUTH_REMOTE_USER` as valid authentication 
types, and docs
   under `docs/admin_docs/configuration/networking-settings.mdx:169` explicitly 
reference
   `AUTH_REMOTE_USER` as a supported mode.
   
   2. Observe that bootstrap exposes `AUTH_TYPE` to the frontend via
   `cached_common_bootstrap_data`, tested in
   `tests/unit_tests/views/test_bootstrap_auth.py:63-76`, where
   `payload["conf"]["AUTH_TYPE"]` is asserted for other modes like `AUTH_OAUTH` 
and
   `AUTH_SAML`.
   
   3. On the frontend, open `superset-frontend/src/constants/auth.ts:20-26`, 
where `AuthType`
   is documented to "mirror Flask-AppBuilder AUTH_TYPE values" but only defines 
`AuthOID =
   0`, `AuthDB = 1`, `AuthLDAP = 2`, `AuthOauth = 4`, and `AuthSAML = 5`, with 
no entry for
   `AUTH_REMOTE_USER`.
   
   4. In `superset-frontend/src/pages/UserInfo/index.tsx:44-46`, see `const 
authType:
   AuthType = getBootstrapData().common.conf.AUTH_TYPE;` which relies on this 
enum; any
   future frontend code needing to branch on `AUTH_REMOTE_USER` cannot write
   `AuthType.AuthRemoteUser` (it does not exist), leading to incorrect 
assumptions about the
   possible AUTH_TYPE values and incomplete handling of a backend-supported 
mode.
   ```
   </details>
   
   [![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=987fc1c977ef4e0297d194695d88c8bc&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=987fc1c977ef4e0297d194695d88c8bc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/constants/auth.ts
   **Line:** 20:26
   **Comment:**
        *Incomplete Implementation: This enum claims to mirror Flask-AppBuilder 
`AUTH_TYPE` values, but it omits the valid `AUTH_REMOTE_USER` value (`3`). That 
creates an incomplete contract for consumers of `AuthType` and can cause wrong 
branching or impossible-type assumptions when bootstrap data contains that auth 
mode. Add the missing enum member so frontend auth-mode checks stay aligned 
with backend constants.
   
   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%2F39469&comment_hash=c22f40162716727b3c988259418d82ddd24b5d9dd9822c58e5c03f0025daebbc&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39469&comment_hash=c22f40162716727b3c988259418d82ddd24b5d9dd9822c58e5c03f0025daebbc&reaction=dislike'>👎</a>



##########
superset-frontend/src/features/userInfo/UserInfoModal.tsx:
##########
@@ -86,30 +142,82 @@ function UserInfoModal({
     </>
   );
 
-  const ResetPasswordFields = () => (
+  const ResetPasswordFields = ({ form }: { form: FormInstance }) => (
     <>
       <FormItem
-        name="password"
-        label={t('Password')}
-        rules={[{ required: true, message: t('Password is required') }]}
+        name="current_password"
+        label={t('Current password')}
+        rules={[{ required: true, message: t('Current password is required') 
}]}
+      >
+        <Input.Password
+          name="current_password"
+          autoComplete="current-password"
+          placeholder={t('Enter your current password')}
+        />
+      </FormItem>
+      <FormItem
+        name="new_password"
+        label={t('New password')}
+        rules={[
+          { required: true, message: t('New password is required') },
+          {
+            validator(_, value) {
+              const password = String(value ?? '');
+              if (!password) {
+                return Promise.resolve();
+              }
+              const errorMessage = getPasswordPolicyError(password);
+              return errorMessage
+                ? Promise.reject(new Error(errorMessage))
+                : Promise.resolve();
+            },
+          },
+        ]}
       >
         <Input.Password
-          name="password"
-          placeholder={t("Enter the user's password")}
+          name="new_password"
+          autoComplete="new-password"
+          placeholder={t('Enter a new password')}
+          suffix={
+            <GeneratePasswordInputSuffix
+              onGenerate={() => {
+                const pwd = generateAuthDbPassword(passwordPolicy);
+                form.setFieldsValue({ new_password: pwd, confirm_password: pwd 
});

Review Comment:
   **Suggestion:** The generated password is written with 
`form.setFieldsValue`, but `FormModal` enables/disables Save using 
`onValuesChange`/`onFieldsChange`. Programmatic `setFieldsValue` updates do not 
reliably trigger those handlers, so after clicking generate the form can remain 
in a stale "Save disabled" state until the user manually edits a field. Trigger 
validation/change recalculation after setting values (or explicitly recompute 
submit state) so generated values immediately make the form submittable. [api 
mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Reset password modal stays disabled after generating a password.
   - ⚠️ AUTH_DB users discouraged from using generated strong passwords.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Start Superset with `AUTH_TYPE = AUTH_DB` (default, configured in
   `superset/config.py:432-437`), log in with a database-backed user, and 
navigate to
   **Settings → User information**, which renders the `UserInfo` page
   (`superset-frontend/src/pages/UserInfo/index.tsx`).
   
   2. In `UserInfo/index.tsx:44-69`, note that when `authType === 
AuthType.AuthDB`, a "Reset
   my password" button (`data-test="reset-password-button"`) opens 
`ChangePasswordModal`,
   which is implemented by `UserInfoModal` with `isEditMode={false}`
   (`superset-frontend/src/pages/UserInfo/index.tsx:47-55` and
   `src/features/userInfo/UserInfoModal.tsx:254-256`).
   
   3. In the reset-password flow, `FormModal` is used with
   `requiredFields=['current_password','new_password','confirm_password']`
   (`UserInfoModal.tsx:81-83, 237-245`), and `FormModal` internally 
enables/disables Save
   based on `onValuesChange`/`onFieldsChange`
   
(`packages/superset-ui-core/src/components/Modal/FormModal.tsx:29-36,48-55`), 
updating
   `submitDisabled` whenever those handlers fire.
   
   4. Open the "Reset password" modal, click the thunderbolt "Generate 
password" suffix in
   the "New password" field (`GeneratePasswordInputSuffix` wired at
   `UserInfoModal.tsx:181-187`), which calls `onGenerate` and executes 
`form.setFieldsValue({
   new_password: pwd, confirm_password: pwd });` (`UserInfoModal.tsx:183-185`); 
because this
   programmatic `setFieldsValue` update does not trigger the
   `onValuesChange`/`onFieldsChange` handlers that `FormModal` relies on, the 
Save button
   (`data-test="form-modal-save-button"`) remains disabled despite both 
required password
   fields being visibly filled until the user manually edits a field.
   ```
   </details>
   
   [![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=4650a8e6f30a42bd8bdada64c668bd25&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=4650a8e6f30a42bd8bdada64c668bd25&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/features/userInfo/UserInfoModal.tsx
   **Line:** 183:185
   **Comment:**
        *Api Mismatch: The generated password is written with 
`form.setFieldsValue`, but `FormModal` enables/disables Save using 
`onValuesChange`/`onFieldsChange`. Programmatic `setFieldsValue` updates do not 
reliably trigger those handlers, so after clicking generate the form can remain 
in a stale "Save disabled" state until the user manually edits a field. Trigger 
validation/change recalculation after setting values (or explicitly recompute 
submit state) so generated values immediately make the form submittable.
   
   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%2F39469&comment_hash=f9fd5577731a71a6a0fa8c0a64aca098aad5b5df80a5d6bdda3d086331b1a8b6&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39469&comment_hash=f9fd5577731a71a6a0fa8c0a64aca098aad5b5df80a5d6bdda3d086331b1a8b6&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