Skip to content

Enhance app config handling #1504

Open
DSingh0304 wants to merge 1 commit intozulip:mainfrom
DSingh0304:fix-config-error-handling
Open

Enhance app config handling #1504
DSingh0304 wants to merge 1 commit intozulip:mainfrom
DSingh0304:fix-config-error-handling

Conversation

@DSingh0304
Copy link
Copy Markdown
Collaborator

@DSingh0304 DSingh0304 commented Mar 22, 2026

Fixes: #1404

This PR improves the error handling and reliability of the enterprise configuration loader in app/common/enterprise-util.ts. Previously, a malformed or missing global_config.json file would cause a TypeError in the renderer process, leading to a permanent blank screen upon application launch.

Technical Changes:

  1. Crash Prevention: Initialized enterpriseSettings to an empty object {}. This ensures that even if JSON parsing fails, subsequent calls to getConfigItem return the provided default value instead of attempting to read from undefined.

  2. Performance Optimization: Added an isReloaded flag to the configuration loader. This ensures the filesystem is only checked and parsed once during the application's lifecycle, rather than re-reading and re parsing on every configuration check.

  3. UI Polish: Implemented an isErrorShown guard to ensure the "Error loading global_config" native dialog box is only presented once to the user, even if multiple configuration items triggered a reload.

Screenshots and screen captures:
image

Platforms this PR was tested on:

  • Windows
  • macOS
  • Linux (Ubuntu 24.04)
Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@DSingh0304 DSingh0304 force-pushed the fix-config-error-handling branch from 08e82ff to b6f70b8 Compare March 22, 2026 18:10
@zulipbot zulipbot added size: XL and removed size: L labels Mar 22, 2026
@DSingh0304 DSingh0304 force-pushed the fix-config-error-handling branch from b6f70b8 to 17752dc Compare March 22, 2026 18:16
This improves the error handling in enterprise util ts when loading
the global config json file. Previously the app would experience a
blank screen if the file was malformed or missing a closing brace.

Key changes:
1. Initialize enterpriseSettings to an empty object to prevent
   TypeError when reading from it after a parse failure.
2. Add an isReloaded flag to prevent the app from re parsing the
   filesystem every time a config item is checked.
3. Use a guard to ensure the error dialog is only shown once.

Fixes zulip#1404.
@DSingh0304 DSingh0304 force-pushed the fix-config-error-handling branch from 17752dc to c27ad40 Compare March 22, 2026 18:20
@DSingh0304
Copy link
Copy Markdown
Collaborator Author

Ready for review!

@DSingh0304 DSingh0304 changed the title Enhance app config handling and add E2E tests for stability Enhance app config handling Mar 22, 2026
@zulipbot zulipbot added size: M and removed size: XL labels Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error handling for invalid JSON in global_config.json

2 participants