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

   ### SUMMARY
   Allows the import API to read the `password` field directly from the YAML 
config file when importing databases, as a fallback when no password is 
provided via the `passwords` form parameter.
   
   #### Problem
   
   When importing databases via `/api/v1/assets/import/` or 
`/api/v1/database/import/`, the password field in the YAML config was being 
ignored. Users had to either:
   
   1. Pass passwords via the separate `passwords` form parameter
   2. Have the password already exist in the database (for updates)
   
   This made it difficult to use CLI tools that inject passwords directly into 
the YAML config before sending the import request.
   
   #### Solution
   
   Modified `load_configs()` in `superset/commands/importers/v1/utils.py` to 
check if a password already exists in the parsed YAML config before falling 
back to the existing database password.
   
   **Password priority order (unchanged for existing behavior):**
   
   1. `passwords` form parameter - highest priority (explicit API override)
   2. **`password` in YAML config** - NEW: use if present in the file
   3. Existing database password - fallback for updates
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   
   1. **Get JWT token:**
   
   ```
   curl -X POST http://localhost:8088/api/v1/security/login \
     -H "Content-Type: application/json" \
     -d '{"username": "admin", "password": "admin", "provider": "db"}'
   
   ```
   
   2. **Export assets:**
   
   ```
   superset-cli --jwt-token <TOKEN> http://localhost:8088/ export-assets 
./test-assets --overwrite
   
   ```
   
   3. **Import with WRONG password:**
   
   ```
   superset-cli --jwt-token <TOKEN> http://localhost:8088/ sync native 
./test-assets --overwrite --db-password <UUID>=wrongpassword
   
   ```
   
   4. **Test connection in Superset UI** → Should **FAIL** ❌
   5. **Import with CORRECT password:**
   
   ```
   superset-cli --jwt-token <TOKEN> http://localhost:8088/ sync native 
./test-assets --overwrite --db-password <UUID>=testpass123
   
   ```
   
   6. **Test connection in Superset UI** → Should **SUCCEED** ✅
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] 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