bito-code-review[bot] commented on code in PR #37183: URL: https://github.com/apache/superset/pull/37183#discussion_r2701270364
########## superset/mcp_service/chart/tool/get_chart_data.py: ########## @@ -42,6 +42,22 @@ logger = logging.getLogger(__name__) +def _get_cached_form_data(form_data_key: str) -> str | None: + """Retrieve form_data from cache using form_data_key. + + Returns the JSON string of form_data if found, None otherwise. + """ + from superset.commands.explore.form_data.get import GetFormDataCommand + from superset.commands.explore.form_data.parameters import CommandParameters + + try: + cmd_params = CommandParameters(key=form_data_key) + return GetFormDataCommand(cmd_params).run() + except Exception as e: Review Comment: <!-- Bito Reply --> This is a code suggestion to improve exception handling by catching specific exceptions (KeyError, ValueError, TypeError) instead of the broad 'Exception' in the _get_cached_form_data function. It aims to be more precise about what errors to handle when retrieving cached form data. **superset/mcp_service/chart/tool/get_chart_data.py** ``` except (KeyError, ValueError, TypeError) as e: ``` -- 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]
