codeant-ai-for-open-source[bot] commented on code in PR #43206:
URL: https://github.com/apache/superset/pull/43206#discussion_r3788720162
##########
tests/unit_tests/charts/test_schemas.py:
##########
@@ -478,3 +478,57 @@ def
test_chart_data_extras_rejects_system_sampling(app_context: None) -> None:
with pytest.raises(ValidationError) as exc_info:
ChartDataExtrasSchema().load({"system_sampling": True})
assert "system_sampling" in exc_info.value.messages
+
+
+def test_post_processing_option_schemas_match_their_functions(
+ app_context: None,
+) -> None:
+ """Every documented post-processing option must be a real parameter.
+
+ `QueryObject.exec_post_processing` dispatches with
+ `getattr(pandas_postprocessing, operation)(df, **options)`, and the
+ per-operation `options` dict is passed through unvalidated. So a field
+ that appears in one of these schemas but not in the corresponding
+ function signature is published in the OpenAPI spec as a valid option
+ while raising `TypeError: <op>() got an unexpected keyword argument` --
+ an HTTP 500 -- for any client that sends it.
+
+ `ChartDataSortOptionsSchema` documented a required `columns` dict and an
+ `aggregates` field, neither of which `sort()` accepts, and
+ `ChartDataProphetOptionsSchema` documented `monthly_seasonality` where
+ `prophet()` takes `daily_seasonality`.
+ """
+ import inspect
+
+ from marshmallow import Schema
+
+ from superset.charts import schemas as chart_schemas
+ from superset.utils import pandas_postprocessing
+
+ mismatches = {}
+ for name, schema_cls in vars(chart_schemas).items():
+ if not (
+ inspect.isclass(schema_cls)
+ and issubclass(schema_cls, Schema)
+ and name.startswith("ChartData")
+ and name.endswith("OptionsSchema")
+ ):
+ continue
+ operation = name[len("ChartData") : -len("OptionsSchema")].lower()
+ function = getattr(pandas_postprocessing, operation, None)
+ if function is None:
+ continue
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> For chart schema validation tests, enforce that schema fields are valid
function parameters, but do not require every function parameter to appear in
the schema; missing schema fields represent documentation gaps to address
separately.
**Applied to:**
- `**/test/**`
- `**/tests/**`
- `**/*test*.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
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]