You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The asset-service.ts functions (fetchAsset, hasNftProduct, fetchAssetMetadata) directly destructure API responses without any runtime validation. If the Numbers Protocol API changes field names, response structure, or data types, the component silently renders undefined values with no error signal — making debugging extremely difficult.
// asset-service.ts line 21-23 — direct destructuring with no validationconst{response: { data },}=awaitresponse.json();// Lines 43-63 — direct field access, any missing field silently becomes undefinedconstassetModel: AssetModel={creator: data.assetCreator,// undefined if renamed to asset_creatorheadline: data.headline,// undefined if removedinitialTransaction: data.initial_transaction,thumbnailUrl: data.thumnail_url,// Note: already has a typo (thumnail)// ...};
If data.assetCreator is renamed to data.asset_creator on the backend, the modal silently shows empty creator info with no console warning or error event.
Proposed Implementation
Add lightweight runtime type guards without adding external dependencies:
// asset-validators.tsinterfaceRawAssetResponse{response: {data: {assetCreator?: string;headline?: string;initial_transaction?: string;// ... all expected fields};};}functionisValidAssetResponse(json: unknown): json is RawAssetResponse{if(!json||typeofjson!=='object')returnfalse;constobj=jsonasRecord<string,unknown>;if(!obj.response||typeofobj.response!=='object')returnfalse;constresp=obj.responseasRecord<string,unknown>;returnresp.data!==undefined&&typeofresp.data==='object';}// Usage in fetchAsset():constjson=awaitresponse.json();if(!isValidAssetResponse(json)){console.error('Unexpected API response structure:',Object.keys(json));return;}const{response: { data }}=json;
Expected Impact
Immediate error detection when API responses change shape
Actionable console warnings identifying exactly which fields are missing
Prevent silent UI corruption — show error state instead of blank fields
Support API versioning — gracefully handle v1→v2 migration
Summary
The
asset-service.tsfunctions (fetchAsset,hasNftProduct,fetchAssetMetadata) directly destructure API responses without any runtime validation. If the Numbers Protocol API changes field names, response structure, or data types, the component silently rendersundefinedvalues with no error signal — making debugging extremely difficult.Affected Files
src/asset/asset-service.ts(lines 21-66, 80-83, 101-111)Current Behavior
If
data.assetCreatoris renamed todata.asset_creatoron the backend, the modal silently shows empty creator info with no console warning or error event.Proposed Implementation
Add lightweight runtime type guards without adding external dependencies:
Expected Impact
Relationship to Other Issues