-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
area:runtime-nodeArea: Node runtime bridgeArea: Node runtime bridgeenhancementNew feature or requestNew feature or request
Description
Overview
Multiple issues relate to inconsistent handling of NaN, Infinity, and invalid numeric values across the codebase. This tracking issue proposes a unified validation layer.
Related Issues
- OptimizedNodeBridge should guard against negative/NaN timeoutMs #114 - OptimizedNodeBridge should guard against negative/NaN timeoutMs
- Python bridge should disallow NaN/Infinity in JSON responses #95 - Python bridge should disallow NaN/Infinity in JSON responses
- Reject NaN/Infinity in JS arguments to avoid silent conversion #93 - Reject NaN/Infinity in JS arguments to avoid silent conversion
- Bridge timeoutMs should be validated to avoid NaN/negative timeouts #87 - Bridge timeoutMs should be validated to avoid NaN/negative timeouts
- JSON fallback should handle NaN/NaT explicitly #45 - JSON fallback should handle NaN/NaT explicitly
Proposed Architecture
1. Configuration Validation (at construction)
function validatePositiveNumber(value: number, name: string): number {
if (!Number.isFinite(value) || value <= 0) {
throw new RangeError(`${name} must be a positive finite number, got: ${value}`);
}
return value;
}2. Argument Validation (before serialization)
function validateSerializable(value: unknown): void {
if (typeof value === 'number' && !Number.isFinite(value)) {
throw new BridgeProtocolError(`Cannot serialize ${value} - NaN/Infinity not supported`);
}
}3. Response Validation (during deserialization)
- Python bridge rejects NaN/Infinity in JSON responses
- JS codec validates numeric values on decode
Acceptance Criteria
- All bridge constructors validate numeric options (timeoutMs, maxLineLength, etc.)
-
BridgeCore.send()validates arguments before serialization - Python bridge returns explicit error for non-finite numbers
- Codec rejects NaN/Infinity during decode
- All 5 related issues can be closed
Scope
This fix touches:
src/runtime/node.ts- constructor validationsrc/runtime/bridge-core.ts- argument validationruntime/python_bridge.py- response validationsrc/utils/codec.ts- decode validation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:runtime-nodeArea: Node runtime bridgeArea: Node runtime bridgeenhancementNew feature or requestNew feature or request