-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Bug Report: OpenRPC Generator Runtime Error - "Cannot read properties of undefined"
Summary
The OpenRPC generator fails with a runtime TypeError when attempting to generate clients from valid OpenRPC schemas. This affects multiple versions across both 1.x and 2.x release lines, making the tool effectively unusable.
Environment
- OS: Windows 11
- Node.js: Latest (via npx)
- Generator Versions Tested:
@open-rpc/generator@2.1.0(latest)@open-rpc/generator@1.22.3@open-rpc/generator@1.18.13@open-rpc/generator@1.15.5
Error Details
Primary Error (v2.1.0)
TypeError: Cannot read properties of undefined (reading 'hooks')
at getComponentFromConfig (C:\Users\xyz\AppData\Roaming\npm\node_modules\@open-rpc\generator\build\index.js:82:32)
at exports.default (C:\Users\xyz\AppData\Roaming\npm\node_modules\@open-rpc\generator\build\index.js:175:33)
at async Command.<anonymous> (C:\Users\xyz\AppData\Roaming\npm\node_modules\@open-rpc\generator\build\index.js:188:9)
Secondary Error (v1.22.3, v1.18.13, v1.15.5)
TypeError: Cannot read properties of undefined (reading 'beforeCopyStatic')
at copyStaticForComponent (...)
Reproduction Steps
Method 1: Command Line Generation
# Create a minimal valid OpenRPC schema
npx @open-rpc/generator generate -d ./schema.json -o ./output -l goMethod 2: Using Init + Config
# This works and creates config
npx @open-rpc/generator init
# But this fails with the error
npx @open-rpc/generator generate -c ./open-rpc-generator-config.jsonMinimal Test Schema
The error occurs even with a minimal, valid OpenRPC 1.3.2 schema:
{
"openrpc": "1.3.2",
"info": {
"title": "Test API",
"version": "1.0.0",
"description": "Minimal test schema"
},
"methods": [
{
"name": "test_method",
"summary": "Test method",
"params": [
{
"name": "param1",
"required": true,
"schema": {
"type": "string"
}
}
],
"result": {
"name": "TestResult",
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
}
]
}Commands That Fail
All of these commands produce the runtime error:
# Latest version
npx @open-rpc/generator@2.1.0 generate -d ./schema.json -o ./output -l go
# Previous stable versions
npx @open-rpc/generator@1.22.3 generate -d ./schema.json -o ./output -l go
npx @open-rpc/generator@1.18.13 generate -d ./schema.json -o ./output -l go
npx @open-rpc/generator@1.15.5 generate -d ./schema.json -o ./output -l goExpected Behavior
The generator should:
- Parse the OpenRPC schema successfully
- Generate the requested client code in the specified language
- Output the generated files to the specified directory
Actual Behavior
The generator:
- Starts processing the schema
- Crashes with a TypeError about undefined properties
- Exits with code 1, generating no output
Impact
This bug makes the OpenRPC generator completely unusable for:
- Generating Go clients (tested language)
- Any client generation workflows
- Integration with build systems and CI/CD pipelines
The error suggests the issue is in the component loading/configuration system, affecting the core functionality regardless of schema validity.
Additional Context
- The
npx @open-rpc/generator initcommand works correctly and creates valid config files - The
--helpand--versioncommands work correctly - The error occurs immediately during generation, suggesting it's not schema-specific
- Multiple users may be affected as this spans several versions
- This prevents adoption of OpenRPC in projects that require reliable code generation
Suggested Investigation
The error patterns suggest:
- v2.1.0: Issue with
hooksproperty access ingetComponentFromConfig - v1.x: Issue with
beforeCopyStaticproperty access incopyStaticForComponent
This might indicate:
- Missing or incorrectly initialized component configuration objects
- Breaking changes in dependency management between versions
- Issues with the component loading system
Would appreciate any guidance on workarounds or timeline for a fix, as this blocks OpenRPC adoption in projects requiring reliable client generation.