Skip to content

[Bug]: ChainService importChain fails when JSON missing steps #3

@SSJane

Description

@SSJane

Bug Description

When importing a valid JSON that lacks the steps property, chainService.importChain() throws a TypeError: Cannot read properties of undefined (reading 'map') instead of the expected Error("Invalid chain data").

Steps to Reproduce

  1. Create a JSON file without a steps field:
   {
     "name": "sample chain"
   }
  1. Call :
await chainService.importChain(validJsonWithoutSteps);

3.Observe the thrown error.

Expected Behavior

The function should throw a controlled error:

Error: Invalid chain data

Actual Behavior

The function throws a TypeError:

Cannot read properties of undefined (reading 'map')

Environment

Vitest/ui v4.0.5
Vitest/coverage-v8 v4.0.4

Node.js v22.2.0

OS: Windows 11

File: src/lib/chain-service.ts

Test file: chain-service.test.ts

Screenshots

Image

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions