aminghadersohi opened a new pull request, #46058:
URL: https://github.com/apache/superset/pull/46058
### SUMMARY
`GET /api/v1/database/_info` and `GET /api/v1/tag/_info` return HTTP 500
when called without a `q` filter (for example `curl /api/v1/database/_info`).
Calling them with `q=(keys:!(permissions))`, which is what the frontend does,
works.
Without `keys`, Flask-AppBuilder builds the add/edit field metadata by
indexing the explicit add/edit marshmallow schema with every column in
`add_columns` / `edit_columns` (`ModelRestApi._get_fields_info` ->
`model_schema.fields[col]`). Two APIs list columns the schema does not define,
so the lookup raises a `KeyError`:
- `DatabaseRestApi`: `encrypted_extra`. The post/put schemas expose
`masked_encrypted_extra`; `encrypted_extra` is only accepted as a legacy alias
through a `pre_load` hook.
- `TagRestApi`: `objects`, `users_favorited`, `created_by`, `changed_by`,
`type`, `created_on`, `changed_on` (default columns not defined on the custom
post/put schemas).
The fix overrides `_get_fields_info` once in `BaseSupersetModelRestApi` and
skips columns without a schema field, since they cannot be described. That
covers every subclass instead of patching each API's column lists. I checked
every `ModelRestApi` view that exposes `_info`: `database` and `tag` were the
only ones returning 500; the rest already returned 200 and `semantic_view` has
no `info` route.
Response change: `add_columns` / `edit_columns` in the `_info` payload no
longer attempt `encrypted_extra` for the database API (it was never returned,
the request failed).
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (API only).
Before: `GET /api/v1/database/_info` -> `500 {"error":
"'encrypted_extra'"}`, `GET /api/v1/tag/_info` -> `500 {"error": "'objects'"}`.
After: both return `200` with `add_columns`, `edit_columns`, `permissions`,
`filters`, etc.
### TESTING INSTRUCTIONS
```
pytest tests/unit_tests/views/test_info_without_filter.py
```
The new tests fail on `master` and pass with this change. Manually: `curl -b
<session> /api/v1/database/_info` and `/api/v1/tag/_info` return 200.
### ADDITIONAL INFORMATION
- [ ] 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]