canopy-network/canopy · error · ValueError

Failed to load config from {filepath}: {err}

Error message

Failed to load config from {filepath}: {err}

What it means

Raised in new_config_from_file when reading or parsing the JSON config file fails (missing file, unreadable path, or invalid JSON), and the underlying exception err is reported. It means the plugin could not build its startup configuration from the given filepath.

Source

Thrown at plugin/python/contract/plugin.py:81

            raise ValueError(f"Invalid data_dir_path: {self.data_dir_path}")


def default_config() -> Config:
    """Return the default configuration (matching Go's DefaultConfig)."""
    return Config(chain_id=1, data_dir_path="/tmp/plugin/", rpc_address="0.0.0.0:50010")


def new_config_from_file(filepath: str) -> Config:
    """Load configuration from JSON file (matching Go's NewConfigFromFile)."""
    try:
        config_data = json.loads(Path(filepath).read_text(encoding="utf-8"))
        return Config(
            chain_id=config_data.get("chainId", 1),
            data_dir_path=config_data.get("dataDirPath", "/tmp/plugin/"),
            rpc_address=config_data.get("rpcAddress", "0.0.0.0:50010"),
        )
    except Exception as err:
        raise ValueError(f"Failed to load config from {filepath}: {err}")


class Plugin:
    """
    Plugin defines the 'VM-less' extension of the Finite State Machine.
    Matches Go's Plugin struct.
    """

    def __init__(self, config: Config):
        self.config = config
        self.fsm_config: Optional[PluginFSMConfig] = None
        self.plugin_config = PluginConfig()
        self._reader: Optional[asyncio.StreamReader] = None
        self._writer: Optional[asyncio.StreamWriter] = None
        self._pending: Dict[int, asyncio.Future] = {}
        self._request_contracts: Dict[int, Contract] = {}
        self._listen_task: Optional[asyncio.Task] = None
        self._message_tasks: Set[asyncio.Task] = set()

View on GitHub (pinned to ee8197d91d)

Solutions

  1. Verify the config file exists at filepath and is readable by the plugin process.
  2. Validate the JSON syntax of the config file (e.g. with a JSON linter) and fix parse errors.
  3. Regenerate the config from default_config() if it is corrupted or lost.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at plugin/python/contract/plugin.py:81 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of canopy-network/canopy@ee8197d91d (2026-09-06). Data as JSON: /api/errors/06ac18bec37147fb. Report an issue: GitHub.