asciidoctor-kroki: Weird error when URI is too long

I’m using this command on a file that contains a very large PlantUML diagram (File --> 062.adoc.txt)

.\asciidoctor -a diagram-server-url=https://kroki.io/ -a diagram-server-type=kroki_io -a kroki-fetch-diagram -r asciidoctor-kroki "C:\Users\team\Desktop\Large output\Includes\062.adoc"

I’m suspecting that the URI is too large but I get the following error:

asciidoctor: FAILED: C:/Users/team/Desktop/Large output/Includes/062.adoc: Failed to load AsciiDoc document - undefined method `request_post’ for Net::HTTP:Class

    res = ::Net::HTTP.request_post(uri, data)
                     ^^^^^^^^^^^^^

Use --trace to show backtrace

The thing is that I was thinking that using the kroki-fetch-diagram attribute should have prevented this kind of error. What am I doing wrong or what I don’t understand?

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Thanks for your input!

Note that the second generation is much faster as far as the existing images are not fetched if I correctly understood the fix.

If the file already exists on disk it should not fetch again from Kroki. I believe that’s why it’s faster.

I think the issue can be closed.

I will keep it open since I think we should add a note in the documentation on how to resolve/workaround the error “414 Uri Too Long”.

Sorry for the delayed reply, I was not able to test anything until now.

You’re right $ asciidoctor-pdf -a kroki-fetch-diagram -r asciidoctor-kroki doc.adoc is working fine. I came to use a different command due to the issue with png file generation on windows (#369). Note that I’m not sure it was related, but this is where I ended up.

So,

  1. I can confirm that I can generate a large document (17+ Mb for the PDF) in PDF or HTML format with the same attributes in the command
  2. I guess that the v0.6.0 also fixed #369. In any case, I could have generated each format (with png and SVG files) twice w/o issues with the images generated. Note that the second generation is much faster as far as the existing images are not fetched if I correctly understood the fix.

Long story short: everything is working! Thanks for your quick and efficient help 🙇‍♂️ 👍

I think the issue can be closed.

OH I see, you need to add kroki-fetch-diagram=true otherwise it will use a GET request (since we don’t download/fetch the diagram from Kroki).

The following command should be enough:

$ asciidoctor-pdf -a kroki-fetch-diagram -r asciidoctor-kroki doc.adoc

Question: Why does the error only appears on a large diagram? (I don’t understand the fix sweat_smile).

You can take a look at: https://docs.kroki.io/kroki/setup/configuration/#_max_uri_length and https://github.com/Mogztter/asciidoctor-kroki/tree/ruby-v0.5.0#configuration

Basically, there’s a URI limit so when the size exceed 4000 characters we switch to POST (instead of GET)