endimonan opened a new pull request, #44000:
URL: https://github.com/apache/superset/pull/44000

   ### SUMMARY
   Editing a database whose connection is down fails with "Connection failed, 
please check your connection settings", even when the only change is unchecking 
"Expose database in SQL Lab". `UpdateDatabaseCommand` runs 
`SyncPermissionsCommand`, which pings the database before syncing permissions 
and raises when the ping fails. The update command only swallowed OAuth2 
errors, so the whole PUT was rolled back.
   
   This change compares the incoming connection settings (name, SQLAlchemy URI, 
extras, server certificate, impersonation, SSH tunnel) with the stored ones 
before applying the update. If none of them changed and the ping fails, the 
permission sync is skipped with a warning and the update goes through. Changing 
the name or any connection setting still requires a successful sync, since 
permissions are name based.
   
   The issue thread points at the frontend `getValidation()` call, but that 
only runs for dynamic-form connections. Druid uses the SQLAlchemy URI form, and 
the toast in the reporter's screenshot is the update error handler wrapping the 
backend message, so the failing request is the PUT itself.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Before: PUT `/api/v1/database/<id>` returns 422 with the connection error 
and nothing is saved.
   After: PUT returns 200, the metadata change is persisted and a warning is 
logged.
   
   ### TESTING INSTRUCTIONS
   1. Create a database connection and confirm it works.
   2. Make it unreachable (stop the database or block the host).
   3. Edit the connection, uncheck "Expose database in SQL Lab" and click 
Finish. The change is saved.
   4. Edit it again and change the password or the database name. It still 
fails with the connection error.
   
   Unit tests:
   ```
   pytest tests/unit_tests/commands/databases/update_test.py 
tests/unit_tests/databases/api_test.py -k "unreachable or missing_old_password"
   ```
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #42043
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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