question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Karate (Thymeleaf -> SAXParser) prints "Fatal Error" when encountering valid HTML5

See original GitHub issue

I am attempting to use Karate to authenticate with our service via an OAuth2 authorization code grant. During the process, my test needs to fetch (and parse, using JSoup in a Java interop) our service’s scope approval web page. This page is valid HTML5 (hopefully), containing unclosed <link> and <meta> tags.

As far as I can tell, karate attempts to parse that page through thymeleaf, which, in turn seems to attempt to use a SAXParser to process. That results in an error message “Fatal Error” in the logs (although the test then continues and succeeds).

I am attaching a trivial feature file html5-fetch.feature.txt to fetch from a stub from a web site of mine.

Unfortunately, I seem to be unable to produce an English error message; the German equivalent is

[Fatal Error] :7:5: Elementtyp "link" muss mit dem entsprechenden Endtag "</link>" beendet werden.
13:24:03.947 [main] WARN  com.intuit.karate - auto-conversion of response failed: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 5; Elementtyp "link" muss mit dem entsprechenden Endtag "</link>" beendet werden.

(seems to translate to org.xml.sax.SAXParseException: Element type "link" must be terminated by a matching end tag "</link>")

I would prefer not having “Fatal Errors” in my test logs, even when they succeed. It does not seem to be a good idea to attempt to parse responses as xml, unless the content type is xml.

I am fine if you regard this topic as a non-issue 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bnutzercommented, Jul 16, 2021

@ptrthomas Perfect! Works for me, fixes both the sample request as well as my production code.

Thanks for your hint for the karate.extract() function. Probably a valuable solution for lots of cases. However, in my case I need to collect all “name” attributes of all html entities with a certain “class” attribute. That’s 3 lines of well readable code using Java, but would be hell of a regex using the “extract” function, I suppose.

The diff looks straight forward and really sensible to me. However, I do understand that this might be breaking for some folks.

Thanks again!

0reactions
ericdriggscommented, Aug 5, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Karate HTML parsing throwing SaxException when document ...
doctype declaration in lower case (perfectly acceptable in 'normal' HTML), I think the Karate XML parser throws a fatal error and warning. It ......
Read more >
Interview Questions Part 1 | Class (Computer Programming)
A. Java Interview Questions 22. Explain the concept of Inheritance? 23. Which class in Java is superclass of every. 1. What is the...
Read more >
Olympic love - Idler Shanghai - Kungfuology
In this post you have showed the pictures of tickets of Olympic games ... Critical temperature in thermodynamics ... HTML5 Server-Sent Event
Read more >
T_站长源码网(Downzz.com) - 网页快照
已有账号?点击注册 忘记密码? 获取验证码. 点击阅读注册协议. 已有账号?点击登录 忘记密码? 搜索. OTCMSsweet博客系统HituxBloghtml5响应式整站源码ISiteISite企业 ...
Read more >
double colon in url is loading indefinitely in a Webview and is ...
so I cannot determine if an error is encountered when loading. I tried to check it the url is valid via this code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found