Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github-action-for-generator: Error: Found non-callable @@iterator #368

Closed
serkmen opened this issue Dec 22, 2023 · 17 comments · Fixed by #375 or asyncapi/asyncapi-react#885
Closed
Labels
bug Something isn't working

Comments

@serkmen
Copy link

serkmen commented Dec 22, 2023

Bug Description:

Following error occurs when generating HTML from my AsyncAPI document with the latest versions of github-action-for-generator and html-template in my GitHub Actions

[BABEL] Note: The code generator has deoptimised the styling of /node_modules/@asyncapi/generator/node_modules/@asyncapi/html-template/template/js/asyncapi-ui.min.js as it exceeds the max of 500KB.
Error: Found non-callable @@iterator

image

How to Reproduce

Please see source files and steps to produce as GitHub Action definition file.

Complete GitHub Action:

name: AsyncAPI documents processing
on: push
permissions:
  contents: write
jobs:
  generate:
    runs-on: ubuntu-latest
    steps:
    #"standard step" where repo needs to be checked-out first
    - name: Checkout repo
      uses: actions/checkout@v2
      
    #Using another action for AsyncAPI for validation
    - name: Validating AsyncAPI document
      uses: WaleedAshraf/asyncapi-github-action@v0.0.10
      with:
        filepath: docs/api/my-asyncapi.yml
      
    #In case you do not want to use defaults, you for example want to use different template
    - name: Generating HTML from my AsyncAPI document
      uses: docker://asyncapi/github-action-for-generator:latest  #always use latest tag as each is pushed to docker
      with:
        template: '@asyncapi/html-template@2.0.0'  #In case of template from npm, because of @ it must be in quotes
        filepath: docs/api/my-asyncapi.yml
        parameters: baseHref=/test-experiment/ sidebarOrganization=byTags #space separated list of key/values
        output: generated-html
        
    #Using another action that takes generated HTML and pushes it to GH Pages
    - name: Deploy GH page
      uses: JamesIves/github-pages-deploy-action@4.0.0
      with:
        ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        BRANCH: feature/asyncapi-integration
        FOLDER: generated-html

API Description Used:

asyncapi: 2.0.0
info:
  title: Account Service
  version: '1.0.0'
  description: |
    Manages user accounts in the system.
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0

servers:
  production:
    url: mqtt://test.mosquitto.org
    protocol: mqtt
    description: Test MQTT broker

channels:
  user/signedup:
    subscribe:
      operationId: emitUserSignUpEvent
      message:
        $ref : '#/components/messages/UserSignedUp'

components:
  messages:
    UserSignedUp:
      name: userSignedUp
      title: User signed up event
      summary: Inform about a new user registration in the system
      contentType: application/json
      payload:
        $ref: '#/components/schemas/userSignedUpPayload'

  schemas:
    userSignedUpPayload:
      type: object
      properties:
        firstName:
          type: string
          description: "foo"
        lastName:
          type: string
          description: "bar"
        email:
          type: string
          format: email
          description: "baz"
        createdAt:
          type: string
          format: date-time
@serkmen serkmen added the bug Something isn't working label Dec 22, 2023
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@serkmen serkmen changed the title ithub-action-for-generator github-action-for-generator: Error: Found non-callable @@iterator Dec 22, 2023
@serkmen
Copy link
Author

serkmen commented Dec 28, 2023

Please also note that error disappears when switching back to html-template@1.0.0 version.
This time blank html case occurs in the generated index.html:

`

<title>Streetlights API 1.0.0 documentation</title>
<body>
  <div id="root"></div>

  <script src="js/asyncapi-ui.min.js" type="application/javascript"></script>

  <script>
    const schema = undefined;
    const config = {"show":{"sidebar":true},"sidebar":{"showOperations":"bySpecTags"}};
    AsyncApiStandalone.hydrate({ schema, config }, document.getElementById("root"));
  </script>
</body>
`

Probably same issue here: [https://github.com/asyncapi/html-template/issues/456]

@derberg
Copy link
Member

derberg commented Jan 8, 2024

Hey there, we just released completely new version of this action, it now uses AsyncAPI CLI under the hood

please try to use docker://asyncapi/github-action-for-cli:3.0.1 and let us know if issue is still there

@pioneer2k
Copy link
Contributor

@derberg

I just tried to use the docker://asyncapi/github-action-for-cli:3.0.1
I get the following error:
/entrypoint.sh: line 19: $1: unbound variable

I also tried to provide "cli_version: latest" but that makes no difference.

@derberg
Copy link
Member

derberg commented Jan 9, 2024

@Shurtu-gal please have a look

@Shurtu-gal
Copy link
Collaborator

@serkmen Couple of things to note :-

  • As this action covers a multitude of functionalities now compared to the earlier generate function. The parameters passed don't just include template params hence you have to pass an -p as shown in the README and in this file example

  • Please use asyncapi/github-action-for-cli@v3.0.1 as shown in GitHub Actions Marketplace.

@Shurtu-gal
Copy link
Collaborator

Shurtu-gal commented Jan 9, 2024

@derberg Should I update the README to do the same instead of docker://?

The problem with our docker image is that our GitHub is not passing any parameters to the docker image as can be seen here.

Earlier it using octokit it could pull params from context of workflow.

@derberg
Copy link
Member

derberg commented Jan 9, 2024

@Shurtu-gal best would be to enable our docker image to work as before, otherwise our action will not be very handy as it will always be delayed by the fact that image will have to be build as part of workflow run. Advantage of docker is that image is already there, so workflow run is much faster

@Shurtu-gal
Copy link
Collaborator

Yeah, I was looking into how others were solving it, got an idea what to do from here

@pioneer2k
Copy link
Contributor

@Shurtu-gal @derberg

I switched everything to your new GitHub Action asyncapi/github-action-for-cli@v3.1.1 but the original error of this issue is still the same.

My action:

       - name: Generating HTML from CheckoutOrders AsyncAPI document
         uses: asyncapi/github-action-for-cli@v3.1.1
         with:
           template: '@asyncapi/html-template@2.0.0'
           filepath: src/main/resources/asyncapi_checkoutOrders.yml
           parameters: --force-write -p baseHref=/checkout-orders-asyncapi-generated-html/ sidebarOrganization=byTags
           output: asyncapi/checkout-orders-asyncapi-generated-html

The output:

AsyncAPI CLI version: @asyncapi/cli/1.3.0 linux-x64 node-v18.19.0
Executing AsyncAPI CLI...
Debug information
Generating from AsyncAPI file...
Debug information
Executing command: asyncapi generate fromTemplate /github/workspace/src/main/resources/asyncapi_checkoutOrders.yml @asyncapi/html-template@2.0.0 -o /github/workspace/asyncapi/checkout-orders-asyncapi-generated-html --force-write -p baseHref=/checkout-orders-asyncapi-generated-html/ sidebarOrganization=byTags
Generation in progress. Keep calm and wait a bit... done

[BABEL] Note: The code generator has deoptimised the styling of /usr/local/lib/node_modules/@asyncapi/cli/node_modules/@asyncapi/generator/node_modules/@asyncapi/html-template/template/js/asyncapi-ui.min.js as it exceeds the max of 500KB.
Generator Error: Found non-callable @@iterator

@Shurtu-gal Shurtu-gal reopened this Jan 15, 2024
@Shurtu-gal
Copy link
Collaborator

I will look into this. Can you send the AsyncAPI spec as well as workflow run? @pioneer2k

@pioneer2k
Copy link
Contributor

@Shurtu-gal
I am not able to send that, as the workflow run is on a GitHub repository of a private organization and the AsyncAPI spec contains confidential information.
Maybe I can provide some other information that can help?

@Shurtu-gal
Copy link
Collaborator

@pioneer2k Was able to reproduce, and from what I could see its a problem with html-template.

  1. It's working with version 0.9.0 as can be seen here
  2. But not with 2.0.0 here

@pioneer2k
Copy link
Contributor

@Shurtu-gal
yes, I know. That was the reason why this issue originally was opened by @serkmen
Migration from html-template 0.28.4 (in my case) to 1.0.0 and 2.0.0 is not working.

@Shurtu-gal
Copy link
Collaborator

image

As can be seen, the 2.0.0 version works with sidebarOrganization as byTagsNoRoot or undefined. Maybe you don't have tags at the root level.

PS:- For further info https://github.com/asyncapi/html-template/#supported-parameters

@pioneer2k
Copy link
Contributor

Yes, you are right. Without the parameter 'sidebarOrganization' it works for me.

@jonaslagoni
Copy link
Member

This should be solved by a fix to the underlying react components: asyncapi/asyncapi-react#885

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants