Skip to content

Conversation

Copy link

Copilot AI commented Oct 29, 2025

Module-level initialization in dashboard.py can fail if SNowInstance().report_filter_config raises an exception, preventing the module from being imported.

Changes:

  • Wrap report_filter_config access in try-except to catch initialization failures
  • Log warnings on exception and fallback to None for both filter constants
  • Move config cleanup into else block to avoid undefined variable errors
# Before
config = SNowInstance().report_filter_config
if config is None:
    REPORT_DATE_FILTER = REPORT_TIME_FILTER = None
else:
    REPORT_DATE_FILTER = config["report_date_filter"]
    REPORT_TIME_FILTER = config["report_time_filter"]
del config

# After
try:
    config = SNowInstance().report_filter_config
except Exception as exc:
    logging.warning("Failed to load report filter config: %s", exc)
    REPORT_DATE_FILTER = REPORT_TIME_FILTER = None
else:
    if config is None:
        REPORT_DATE_FILTER = REPORT_TIME_FILTER = None
    else:
        REPORT_DATE_FILTER = config["report_date_filter"]
        REPORT_TIME_FILTER = config["report_time_filter"]
    del config

This ensures the module imports successfully even when ServiceNow instance access fails.

Original prompt

On dashboard.py:33-38, Make a PR with the following changes.


try:
config = SNowInstance().report_filter_config
except Exception as exc:
logging.warning("Failed to load report filter config: %s", exc)
REPORT_DATE_FILTER = REPORT_TIME_FILTER = None
else:
if config is None:
REPORT_DATE_FILTER = REPORT_TIME_FILTER = None
else:
REPORT_DATE_FILTER = config["report_date_filter"]
REPORT_TIME_FILTER = config["report_time_filter"]
del config



✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix report filter config loading in dashboard.py Add exception handling to report filter config loading in dashboard.py Oct 29, 2025
Copilot finished work on behalf of amanjaiswal73892 October 29, 2025 13:18
@amanjaiswal73892 amanjaiswal73892 marked this pull request as ready for review October 29, 2025 13:18
@amanjaiswal73892 amanjaiswal73892 requested review from aldro61 and removed request for amanjaiswal73892 October 29, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants