superfaceai / cli

Let AI connect the APIs for you
https://superface.ai
MIT License
23 stars 4 forks source link

[BUG] create:map fails with untyped fields #273

Closed jnv closed 1 year ago

jnv commented 1 year ago

Given a profile which contains a use case like:

usecase Request safe {
  input {
    headers string
    body
  }

  result {
    ok boolean
  }
}

I run sf create:map with this profile.

Expected Behavior

Map is created.

Current Behavior

I get an error: Error: Type is undefined with no futher information.

Rerunning the cli with DEBUG='*' gives me the following stack trace:

Error: Type is undefined
    at .../node_modules/@superfaceai/cli/dist/templates/prepared-map/usecase/example/structure-tree/parse.js:96:23
    at Array.map (<anonymous>)
    at visitObjecDefinition (.../node_modules/@superfaceai/cli/dist/templates/prepared-map/usecase/example/structure-tree/parse.js:91:35)
    at visit (.../node_modules/@superfaceai/cli/dist/templates/prepared-map/usecase/example/structure-tree/parse.js:12:20)
    at Object.parse (.../node_modules/@superfaceai/cli/dist/templates/prepared-map/usecase/example/structure-tree/parse.js:5:12)
    at extractExample (.../node_modules/@superfaceai/cli/dist/templates/prepared-map/usecase/example/build.js:11:33)
    at .../node_modules/@superfaceai/cli/dist/templates/prepared-map/usecase/example/build.js:30:24
    at Array.map (<anonymous>)
    at Object.buildUseCaseExamples (.../node_modules/@superfaceai/cli/dist/templates/prepared-map/usecase/example/build.js:27:45)
    at .../node_modules/@superfaceai/cli/dist/templates/prepared-map/usecase/prepare-usecase-detail.js:24:34

Steps to Reproduce

  1. Create a profile foo with a use case containing an untyped field and any provider bar
  2. Run superface create:map foo bar
  3. Observe the error

Your Environment

@superfaceai/cli/3.0.1 linux-x64 node-v18.12.1 (with @superfaceai/one-sdk@2.4.1, @superfaceai/parser@2.1.0)
jnv commented 1 year ago

Fixed in v3.0.2 by #274