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

Option "errors: true" shows empty/blank page when document has errors #874

Open
ivangsa opened this issue Dec 18, 2023 · 4 comments
Open
Labels

Comments

@ivangsa
Copy link

ivangsa commented Dec 18, 2023

Description

As reported in VSCode AsyncAPI Preview:
asyncapi/vs-asyncapi-preview#200

After upgrading to latest: "@asyncapi/react-component": "^1.2.7"

It shows a blank page when document contains validation errors

This are the configuration options used:
image

@ashmit-coder
Copy link

hey @ivangsa
The issue seems to occur due to unhandled undefined of the document object

try {
      const { document } = await asyncapiParser.parse(content, parserOptions);
      return { asyncapi: document };
    } catch (err) {
      return this.handleError(err as ErrorObject);
    }

Here the document object turns out undefined and hence no error is thrown.

try {
      const parseResult = await asyncapiParser.parse(content, parserOptions);

      let error:({title:string} ) = {title:""};
      if(parseResult.document === undefined) {

        parseResult.diagnostics.forEach(diagnostic => {
          if(diagnostic.code.toString().includes("error")) {
            error.title = diagnostic.message.toString();
          }
        });

        if(error.title === "") {
          error.title = "Unexpected error while parsing the document.";
        }

        throw error;
      }

      return { asyncapi: parseResult.document };
    } catch (err) {
      return this.handleError(err as ErrorObject);
    }

This is one way we could resolve this issue.

I will draft a PR for the same and we can communicate over it.

@ashmit-coder
Copy link

Hey @derberg if you may help guide through this it will be great.

@ashmit-coder
Copy link

This maybe an upstream error as the parser does not throw an error as of the latest version but rather an undefined document object witth a error message in the diganostic object

Copy link

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants