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

Aggregate errors in xsd:import|include@schemaLocation for referenced grammar which have errors #596

Closed
Mooninaut opened this issue Sep 27, 2021 · 3 comments · Fixed by eclipse/lemminx#1117
Assignees
Labels
bug Something isn't working validation xsd
Milestone

Comments

@Mooninaut
Copy link

Mooninaut commented Sep 27, 2021

Opening any XSD file that attempts to import a no-longer-present http[s]-served XML Schema with the VSCode XML plugin, version v0.18.0 active causes a large number of errors to appear in the Problems pane. These are a result of attempting to parse a web page as an XSD.

Steps to reproduce

  1. Install and activate the XML Language Support by Red Hat plugin in Visual Studio Code.
  2. Download http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd
  3. Open j2ee_1_4.xsd in Visual Studio Code.

Observed result

See attached screenshot. The majority of the file is highlighted as an error. Many error messages like the following appear in the Problems view:

s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'digitalData = {'.

Confusingly, from a user's perspective, the error messages imply that the source code of that IBM webpage is present immediately following the closing angle bracket of the opening xsd:schema tag. The error highlight continues from that point until the end of the file.

Cause

j2ee_1_4.xsd lines 85-86 contain an import directive for http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd, which is no longer present at that location. There is an HTTP redirect to a regular web page, https://www.ibm.com/products/software

Expected result

  • The plugin gives a useful error message, indicating that a (perhaps transitively) imported schema is invalid, not the currently open file.
  • The plugin highlights the location of problematic import(s) in the currently open file, rather than highlighting the whole file contents.
  • In cases of transitive imports, the error message includes the "path" to the invalid schema, such as "http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd is invalid, imported at http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd [85,3], imported at deployment_plan.xsd [21,3]"
  • The plugin detects and rejects an imported "schema" that starts with any of the usual indications of an HTML document, such as <!DOCTYPE html>, <html>, etc. with a useful error message.

Screenshot

XSD error

@angelozerr
Copy link
Contributor

Thanks for reporting this issue @Mooninaut

I tested quickly your usecase and indeed the error reporting is totally unusable. It requires some investigation how to fix this problem.

@angelozerr angelozerr added bug Something isn't working validation xsd labels Sep 29, 2021
@angelozerr angelozerr self-assigned this Sep 29, 2021
angelozerr added a commit to angelozerr/lemminx that referenced this issue Sep 30, 2021
angelozerr added a commit to angelozerr/lemminx that referenced this issue Sep 30, 2021
angelozerr added a commit to angelozerr/lemminx that referenced this issue Sep 30, 2021
@angelozerr angelozerr changed the title Confusing error messages when XML schema location redirects to an HTML page Aggregate errors in xsd:import|include@schemaLocation for referenced grammar which have errors Sep 30, 2021
angelozerr added a commit to angelozerr/lemminx that referenced this issue Sep 30, 2021
grammar which have errors

Fixes redhat-developer/vscode-xml#596

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr angelozerr added this to the 0.18.1 milestone Sep 30, 2021
angelozerr added a commit to angelozerr/lemminx that referenced this issue Oct 5, 2021
grammar which have errors

Fixes redhat-developer/vscode-xml#596

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Oct 5, 2021
grammar which have errors

Fixes redhat-developer/vscode-xml#596

Signed-off-by: azerr <azerr@redhat.com>
@rgrunber
Copy link
Member

rgrunber commented Oct 5, 2021

I'm able to reproduce as well. However, @angelozerr , do you also notice the following behaviour ? If the ~/.lemminx cache is empty, it takes a few attempts to have diagnostics show.

re-validation-error

Even with the PR, which is fixing things I notice the behaviour so maybe a separate issue ?

UPDATE :

stacktrace
Oct 05, 2021 3:16:18 PM org.eclipse.lemminx.extensions.xsd.participants.diagnostics.XSDValidator doDiagnostics
SEVERE: Unexpected XSDValidator error
org.eclipse.lemminx.uriresolver.CacheResourceDownloadingException: The resource 'http://www.w3.org/2001/xml.xsd' is downloading.
	at org.eclipse.lemminx.uriresolver.CacheResourcesManager.getResource(CacheResourcesManager.java:159)
	at org.eclipse.lemminx.extensions.contentmodel.uriresolver.XMLCacheResolverExtension.getCachedResource(XMLCacheResolverExtension.java:100)
	at org.eclipse.lemminx.extensions.contentmodel.uriresolver.XMLCacheResolverExtension.resolveEntity(XMLCacheResolverExtension.java:78)
	at org.eclipse.lemminx.uriresolver.URIResolverExtensionManager.resolveEntity(URIResolverExtensionManager.java:124)
	at org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.resolveDocument(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
	at org.eclipse.lemminx.extensions.xsd.participants.diagnostics.LSPXMLGrammarPreparser.preparseGrammar(LSPXMLGrammarPreparser.java:55)
	at org.eclipse.lemminx.extensions.xsd.participants.diagnostics.XSDValidator.doDiagnostics(XSDValidator.java:103)
	at org.eclipse.lemminx.extensions.xsd.participants.diagnostics.XSDDiagnosticsParticipant.doDiagnostics(XSDDiagnosticsParticipant.java:49)
	at org.eclipse.lemminx.services.XMLDiagnostics.doExtensionsDiagnostics(XMLDiagnostics.java:64)
	at org.eclipse.lemminx.services.XMLDiagnostics.doDiagnostics(XMLDiagnostics.java:46)
	at org.eclipse.lemminx.services.XMLLanguageService.doDiagnostics(XMLLanguageService.java:168)
	at org.eclipse.lemminx.services.XMLLanguageService.publishDiagnostics(XMLLanguageService.java:177)
	at org.eclipse.lemminx.XMLTextDocumentService.validate(XMLTextDocumentService.java:621)
	at org.eclipse.lemminx.XMLTextDocumentService.lambda$triggerValidationFor$32(XMLTextDocumentService.java:589)
	at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:714)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

angelozerr added a commit to eclipse/lemminx that referenced this issue Oct 6, 2021
grammar which have errors

Fixes redhat-developer/vscode-xml#596

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr
Copy link
Contributor

Even with the PR, which is fixing things I notice the behaviour so maybe a separate issue ?

It's an another problem with cache, I created an issue for this problem at eclipse/lemminx#1121

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