You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "fgvieira (via GitHub)" <gi...@apache.org> on 2024/06/18 08:51:12 UTC
[I] 500 error and unexpected keyword argument 'extra_filters' [superset]
fgvieira opened a new issue, #29289:
URL: https://github.com/apache/superset/issues/29289
### Bug description
When trying to access `superset` through the browser I get a 500 error and the logs say:
```
2024-06-18 10:45:34,669:WARNING:root:Class 'werkzeug.local.LocalProxy' is not mapped
monkey_patch_field_process.<locals>.process() got an unexpected keyword argument 'extra_filters'
Traceback (most recent call last):
File "envs/superset/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "envs/superset/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "envs/superset/lib/python3.11/site-packages/flask_appbuilder/security/views.py", line 526, in login
form = LoginForm_db()
^^^^^^^^^^^^^^
File "envs/superset/lib/python3.11/site-packages/wtforms/form.py", line 208, in __call__
return type.__call__(cls, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "envs/superset/lib/python3.11/site-packages/flask_wtf/form.py", line 73, in __init__
super().__init__(formdata=formdata, **kwargs)
File "envs/superset/lib/python3.11/site-packages/wtforms/form.py", line 286, in __init__
self.process(formdata, obj, data=data, **kwargs)
File "envs/superset/lib/python3.11/site-packages/wtforms/form.py", line 127, in process
field.process(formdata, data, extra_filters=field_extra_filters)
```
### How to reproduce the bug
1. `micromamba env create --name superset -c conda-forge superset pillow psycopg2-binary`
2. `export FLASK_APP=superset`
3. `export SUPERSET_CONFIG_PATH=/var/superset/config.py` (the same as in [here](https://superset.apache.org/docs/configuration/configuring-superset/))
4. `superset db upgrade`
5. `superset fab create-admin`
6. `superset init`
Access `superset on browser.
### Screenshots/recordings
_No response_
### Superset version
4.0.1
### Python version
3.11
### Node version
I don't know
### Browser
Firefox
### Additional context
_No response_
### Checklist
- [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
--
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: notifications-unsubscribe@superset.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 500 error and unexpected keyword argument 'extra_filters' [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #29289: 500 error and unexpected keyword argument 'extra_filters'
URL: https://github.com/apache/superset/issues/29289
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 500 error and unexpected keyword argument 'extra_filters' [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #29289:
URL: https://github.com/apache/superset/issues/29289#issuecomment-2341357259
@johnarevalo any ideas of how to fix forward? By all accounts on the thread you linked, the problem should be resolved. Is it possible to roll back to any other 3.x.x releases, at least?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 500 error and unexpected keyword argument 'extra_filters' [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #29289:
URL: https://github.com/apache/superset/issues/29289#issuecomment-2175608327
<!-- Answer -->
The `extra_filters` argument is used in the `getFormDataWithExtraFilters` function to handle additional filters applied to charts in Superset. This function processes the `extra_filters` argument to generate the necessary form data for rendering charts.
Here's an example of how `getFormDataWithExtraFilters` is used:
```ts
export default function getFormDataWithExtraFilters({
chart,
filters,
nativeFilters,
chartConfiguration,
colorScheme,
colorNamespace,
sliceId,
dataMask,
extraControls,
labelColors,
sharedLabelColors,
allSliceIds,
}: GetFormDataWithExtraFiltersArguments) {
// if dashboard metadata + filters have not changed, use cache if possible
const cachedFormData = cachedFormdataByChart[sliceId];
if (
cachedFiltersByChart[sliceId] === filters &&
areObjectsEqual(cachedFormData?.color_scheme, colorScheme, {
ignoreUndefined: true,
}) &&
areObjectsEqual(cachedFormData?.color_namespace, colorNamespace, {
ignoreUndefined: true,
}) &&
areObjectsEqual(cachedFormData?.label_colors, labelColors, {
ignoreUndefined: true,
}) &&
areObjectsEqual(cachedFormData?.shared_label_colors, sharedLabelColors, {
ignoreUndefined: true,
}) &&
!!cachedFormData &&
areObjectsEqual(cachedFormData?.dataMask, dataMask, {
ignoreUndefined: true,
}) &&
areObjectsEqual(cachedFormData?.extraControls, extraControls, {
ignoreUndefined: true,
})
) {
return cachedFormData;
}
let extraData: { extra_form_data?: JsonObject } = {};
const activeFilters = getAllActiveFilters({
chartConfiguration,
dataMask,
nativeFilters,
allSliceIds,
});
const filterIdsAppliedOnChart = Object.entries(activeFilters)
.filter(([, { scope }]) => scope.includes(chart.id))
.map(([filterId]) => filterId);
if (filterIdsAppliedOnChart.length) {
extraData = {
extra_form_data: getExtraFormData(dataMask, filterIdsAppliedOnChart),
};
}
const formData = {
...chart.form_data,
label_colors: labelColors,
shared_label_colors: sharedLabelColors,
...(colorScheme && { color_scheme: colorScheme }),
extra_filters: getEffectiveExtraFilters(filters),
...extraData,
...extraControls,
};
cachedFiltersByChart[sliceId] = filters;
cachedFormdataByChart[sliceId] = { ...formData, dataMask, extraControls };
return formData;
}
```
Ensure that the `getFormDataWithExtraFilters` function is correctly defined and used in your codebase. If the function is not handling the `extra_filters` argument properly, you may need to update it to ensure it processes the `extra_filters` argument as expected <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 500 error and unexpected keyword argument 'extra_filters' [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #29289:
URL: https://github.com/apache/superset/issues/29289#issuecomment-2791191146
Assuming @johnarevalo has moved on, and closing this as stale/not-planned, but we're available if you want to reopen this and/or get a PR merged. Thanks!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 500 error and unexpected keyword argument 'extra_filters' [superset]
Posted by "fgvieira (via GitHub)" <gi...@apache.org>.
fgvieira commented on issue #29289:
URL: https://github.com/apache/superset/issues/29289#issuecomment-2175594460
@dosu I think the issue is with `monkey_patch_field_process.<locals>.process() got an unexpected keyword argument 'extra_filters'`. Any idea what that argument is?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 500 error and unexpected keyword argument 'extra_filters' [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #29289:
URL: https://github.com/apache/superset/issues/29289#issuecomment-2175583746
<!-- Answer -->
To resolve the 500 error and the unexpected keyword argument 'extra_filters' issue, follow these steps:
1. **Check Superset Configuration**:
Ensure that `DEBUG` mode is set to `False` in your Superset configuration. This affects error handling behavior.
2. **Review Error Handling Code**:
The error handling code in `superset/views/base.py` handles different exceptions and returns appropriate responses. For HTTP 500 errors, it serves a static HTML file if `DEBUG` is `False`.
3. **Verify Static Assets**:
Ensure the static HTML file for the 500 error exists at `static/assets/500.html`:
```python
path = files("superset") / "static/assets/500.html"
return send_file(path, max_age=0), 500
```
4. **Enable Stacktrace for Debugging**:
Temporarily enable stacktrace in the configuration to get more details about the error:
```python
def get_error_msg() -> str:
if conf.get("SHOW_STACKTRACE"):
error_msg = traceback.format_exc()
else:
error_msg = "FATAL ERROR \n"
error_msg += (
"Stacktrace is hidden. Change the SHOW_STACKTRACE "
"configuration setting to enable it"
)
return error_msg
```
5. **Check Logs**:
Review the logs for warnings or exceptions that might provide more context about the 500 error:
```python
logger.warning("HTTPException", exc_info=True)
logger.exception(ex)
```
6. **Return JSON Error Response**:
Ensure the JSON error response is returned correctly if the request is not for HTML:
```python
return json_errors_response(
errors=[
SupersetError(
message=utils.error_msg_from_exception(ex),
error_type=SupersetErrorType.GENERIC_BACKEND_ERROR,
level=ErrorLevel.ERROR,
),
],
status=ex.code or 500,
)
```
Additionally, there have been recent updates in the `flask` and `flask_wtf` libraries that could affect form handling:
- `flask` updated to version 2.2.5
- `flask_wtf` updated to version 1.1.0
Review the release notes for these versions to identify specific changes that could impact the `LoginForm_db` class <sup>[[1]](https://github.com/apache/superset/blob/master/superset/views/base.py)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/pyproject.toml)</sup>.
Finally, ensure your `superset/config.py` file has the correct configurations for CSRF protection:
- **WTF_CSRF_ENABLED**:
```python
WTF_CSRF_ENABLED = True
```
- **WTF_CSRF_EXEMPT_LIST**:
```python
WTF_CSRF_EXEMPT_LIST = [
"superset.views.core.log",
"superset.views.core.explore_json",
"superset.charts.data.api.data",
]
```
- **WTF_CSRF_TIME_LIMIT**:
```python
WTF_CSRF_TIME_LIMIT = int(timedelta(weeks=1).total_seconds())
```
These configurations control CSRF protection settings, which directly impact how `LoginForm_db` interacts with `wtforms` and `flask_wtf` <sup>[[3]](https://github.com/apache/superset/blob/master/superset/config.py)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 500 error and unexpected keyword argument 'extra_filters' [superset]
Posted by "johnarevalo (via GitHub)" <gi...@apache.org>.
johnarevalo commented on issue #29289:
URL: https://github.com/apache/superset/issues/29289#issuecomment-2341321222
It seems related to https://github.com/pallets-eco/flask-admin/issues/2142. It worked after downgrading `wtforms` from `3.1.2` to `2.3.3`
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org