-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
asciidoctor-kroki breaks when using remote content repositories #416
Comments
Could you please tell me what is the value of |
This error usually comes from Node.js when using @mojavelinux Is it possible to retrieve the |
Before I can investigate, I need a reproducible test case or example to work with. https://github.com/acme-dope/cloudops-docs.git is not a real git repository, so there's no way for me to test this right now. I'm not going to spend the time to set up the scenario on my own since a) I may not reproduce the scenario correctly and b) it's not fair for me to have to do that. |
If |
The error is captured by the Asciidoctor Kroki extension. My question was, can the extension be aware of the try {
// code...
} catch (err) {
logger.warn('Something went wrong, ignoring...')
if (stacktrace) {
console.trace()
}
} |
Ah, I see. Good question. The stacktrace option specified on the commandline is not directly accessible from an Asciidoctor extension*. See https://gitlab.com/antora/antora/-/blob/main/packages/cli/lib/cli.js#L116. You could, of course, look for it in the process args. But I don't recommend doing that. Instead, this error should either be logged or thrown. And when it is logged, the stack should be preserved. That way, it falls through to Antora's CLI or logger to be reported. Extensions should not try to process or swallow this information (unless the message contains all the necessary information). In short, the information should bubble up. Here's how we preserve the stack inside of Antora: https://gitlab.com/antora/antora/-/blob/main/packages/content-aggregator/lib/aggregate-content.js#L987-1017 Here's how we log an error in an extension: https://gitlab.com/antora/antora-assembler/-/blob/main/packages/assembler/lib/asciidoctor/reducer-extension.js#L181 (however, the error object should be logged instead of just the message). (*) I do wonder if we should transfer this option to a key in the playbook's runtime category. Hmmm. |
@ggrossetie
@ggrossetie Yes. Very hard and non-trivial :) fwiw during setting up the test case is verified (once again) that it's the remote content-source causing the problem, and that we don't hit the kroki-server (or parse the value) before we get the error. I'm not familiar with the pipeline, but maybe that bit of information is useful to you.
@mojavelinux @ggrossetie Sure, I followed the contributing guidelines that I was able to find. Not everybody wants a complete repro. I put it up @ joostschriek/antora-kroki-problem. The reproduction can be done by commenting out the remote-content-source for the local-content-source. some more bash and debug outputswhat the site looks like with the remote-content-source The remote-content-source run joost at acidburn in ~/src/joostschriek/kroki-antora-problem on master [!]
$ antora --stacktrace playbook.yml
[clone] https://github.com/joostschriek/kroki-antora-problem.git [###################################################################]
Skipping diagramsnet block macro. The "path" argument must be of type string. Received undefined
Skipping diagramsnet block macro. The "path" argument must be of type string. Received undefined
Site generation complete!
Open file:///home/joost/src/joostschriek/kroki-antora-problem/build/site in a browser to view your site. and the file tree looks like this the local-content-source run joost at acidburn in ~/src/joostschriek/kroki-antora-problem on master [!]
$ antora --stacktrace playbook.yml
Site generation complete!
Open file:///home/joost/src/joostschriek/kroki-antora-problem/build/site in a browser to view your site. |
The complete stacktrace:
And the cause is that We are using |
It definitely looks better using the Logger from the parent document (Asciidoctor): const errWrapper = new Error(`Skipping ${diagramType} block.`)
errWrapper.stack += `\nCaused by: ${err.stack || 'unknown'}`
parent.getDocument().getLogger().warn({ err: errWrapper }) Current output
Expected outputWould it be possible to use
Edit: Ideally, something like that would be great: parent.getDocument().getLogger().warn({ cause: err }, `Skipping ${diagramType} block.`) |
i'm guessing that the antora (component of kroki?) with remote-content-sources returns relative paths, which is why this is error out? |
If Asciidoctor Kroki requires a file to be at an absolute path on the file system, it must write that file to disk and use that temporary file. Files in Antora are virtual / in-memory. Extensions should adhere to this contract. They should not behave differently if the file is sourced from the git tree instead of the worktree. (I want to clarify that the distinction in Antora is not "remote content sources" vs "local content sources". Rather, it's whether a file is taken from a git tree (the git index) or it is taken from a worktree (a checked out copy of a ref, which equates to files on the local filesystem)). |
I think we need to rethink how to implement the preprocessor that resolves PlantUML But before that I think we need to specify how it should work. Currently, we are trying to resolve them using Antora Resource IDs and/or using a relative paths. I'm not sure what is the best practice here. Anyway, until we specify how it should work, my quick fix is to use Regarding the logger, is it possible to use a message AND a data object. If not I think I will use an I guess I could also add the |
@ggrossetie i made an attempt at spot fixing this issue, i'm sure you'll let me know if everything's ok 😃 |
We are going to establish a contract here in Antora. If you set the |
This should work fine. However, you need to make sure that the code calls the write API. You can find an example in Antora's own include extension. See https://gitlab.com/antora/antora/-/blob/main/packages/asciidoc-loader/lib/include/resolve-include-file.js When running an Antora, a portable extension should never rely on |
…ded to be informational (and can be undefined)
@mojavelinux I get a |
We should _not_ rely on abspath since this property is intended to be informational (and can be undefined).
The object has to be created with message_with_context. See https://gitlab.com/antora/antora/-/blob/main/packages/asciidoc-loader/lib/include/include-processor.js#L186-192 |
We should _not_ rely on abspath since this property is intended to be informational (and can be undefined).
we have various playbooks and remote content sources setup. we've recently introduced kroki as a way to not manually copy paste diagrams from MSPaint or lucid w/e. While this all works perfectly with local content sources, having them as remote content sources results in the following error;
During our builds we install all the required npm extensions;
we call the extensions like so
During our debugging we've figured out that local works but remote doesn't. We've tried the following remediations;
A remote playbook
A local playbook
The text was updated successfully, but these errors were encountered: