Skip to content

Conversation

@calvinleng-science
Copy link
Contributor

@calvinleng-science calvinleng-science commented Sep 10, 2025

Summary

Added error messages for the following cases when using synapsectl -u foo configure and synapsectl -u foo start:

  • Config JSON file not found
  • Config JSON no read permissions
  • file.read() generic exception message
    and more importantly:
  • catching the exceptions informing about syntax errors in the config JSON file thrown by google.protobuf.json_format.Parse

Motivation

Previously, every single error in the configuration process would simply give this error message:

Uncaught error during function. Why: Could not parse ../app-name/config.json as either device configuration or manifest

This would be the case even if the file was not found, which was not informative if they typo'd the filename. The message would also be not informative if they did not have read permissions for the file. It now prints an informative error message for these cases.

The syntax error messages though is especially helpful, as it'll inform users on how to debug where syntax errors occur in their config. Now, it will print something along the lines of (Case: forgot ending quote):

[15:26:46]  Uncaught error during function. Why: Could not parse ../synapse-spike-detect/config/simulator.json as either format:                        __main__.py:96
             - DeviceConfiguration: Failed to load JSON: Expecting property name enclosed in double quotes: line 14 column 5 (char 257).                              
             - AppManifest: Failed to load JSON: Expecting property name enclosed in double quotes: line 14 column 5 (char 257).  

or something like (Case: forgot to put value in field)

[15:28:34]  Uncaught error during function. Why: Could not parse ../synapse-spike-detect/config/simulator.json as either format:                        __main__.py:96
             - DeviceConfiguration: Failed to load JSON: Expecting value: line 9 column 28 (char 180).                                                                
             - AppManifest: Failed to load JSON: Expecting value: line 9 column 28 (char 180).  

or even incompatibilities with Synapse API (Case: typo'd enum value w.r.t. Synapse API):

[15:29:00]  Uncaught error during function. Why: Could not parse ../synapse-spike-detect/config/simulator.json as either format:                        __main__.py:96
             - DeviceConfiguration: Failed to parse nodes field: Failed to parse type field: Invalid enum value kApplicationasdfasf for enum type                     
           synapse.NodeType at DeviceConfiguration.nodes[0].type..                                                                                                    
             - AppManifest: Message type "synapse.AppManifest" has no field named "nodes" at "AppManifest".                                                           
            Available Fields(except extensions): "['name', 'configSchema', 'deviceConfig']"  

Copy link
Contributor

@namthor9 namthor9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@calvinleng-science calvinleng-science merged commit 782d3bc into main Sep 11, 2025
2 checks passed
@calvinleng-science calvinleng-science deleted the calvin/better-config-errors branch September 11, 2025 22:14
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.

3 participants