redhat-developer / redhat-developer/quarkus-ls

Deleting included template causes Exception in validation

Open
#935 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug qute validation
Dominant language
Java
Stars
50
Forks
18
Avg merge
22h 11m
Merged PRs (30d)
3

Description

If you have a page.qute.html with an include like

{#include includes/footer}

{/}

After deleting the includes directory, saving page.qute.html shows Qute LS throwing an exception:


[Trace - 15:38:03] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
    "changes": [
        {
            "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/target/classes/templates/includes/footer.html",
            "type": 3
        }
    ]
}



[Trace - 15:40:30] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/page.qute.html"
    }
}


[Trace - 15:40:30] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
    "changes": [
        {
            "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/page.qute.html",
            "type": 2
        }
    ]
}


[Trace - 15:40:30] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/page.qute.html",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 30,
                    "character": 10
                },
                "end": {
                    "line": 30,
                    "character": 25
                }
            },
            "severity": 1,
            "code": "TemplateNotFound",
            "source": "qute",
            "message": "Template not found: `includes/footer`."
        }
    ]
}


[Trace - 15:40:30] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/template.html",
    "diagnostics": []
}


Sep 14, 2023 3:40:30 PM com.redhat.qute.project.documents.QuteClosedTextDocument loadTemplate
SEVERE: Error while loading closed template 'file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/includes/footer.html'.
java.io.FileNotFoundException: /Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/includes/footer.html (No such file or directory)
	at java.base/java.io.FileInputStream.open0(Native Method)
	at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
	at com.redhat.qute.utils.IOUtils.getContent(IOUtils.java:29)
	at com.redhat.qute.project.documents.QuteClosedTextDocument.loadTemplate(QuteClosedTextDocument.java:74)
	at com.redhat.qute.project.documents.QuteClosedTextDocument.getTemplate(QuteClosedTextDocument.java:64)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.triggerValidationFor(TemplateFileTextDocumentService.java:392)
	at com.redhat.qute.ls.QuteTextDocumentService.triggerValidationFor(QuteTextDocumentService.java:325)
	at com.redhat.qute.ls.QuteLanguageServer.triggerValidationFor(QuteLanguageServer.java:333)
	at com.redhat.qute.project.QuteProject.validateClosedTemplates(QuteProject.java:152)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.triggerValidationFor(TemplateFileTextDocumentService.java:448)
	at com.redhat.qute.ls.QuteTextDocumentService.triggerValidationFor(QuteTextDocumentService.java:335)
	at com.redhat.qute.ls.QuteLanguageServer.triggerValidationFor(QuteLanguageServer.java:343)
	at com.redhat.qute.project.QuteProjectRegistry.didChangeWatchedFiles(QuteProjectRegistry.java:390)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.didChangeWatchedFiles(TemplateFileTextDocumentService.java:385)
	at com.redhat.qute.ls.QuteTextDocumentService.didChangeWatchedFiles(QuteTextDocumentService.java:320)
	at com.redhat.qute.ls.QuteLanguageServer.didChangeWatchedFiles(QuteLanguageServer.java:317)
	at com.redhat.qute.ls.QuteWorkspaceService.didChangeWatchedFiles(QuteWorkspaceService.java:60)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at com.redhat.qute.ls.commons.ParentProcessWatcher.lambda$apply$0(ParentProcessWatcher.java:148)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Sep 14, 2023 3:40:30 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification
WARNING: Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "workspace/didChangeWatchedFiles",
  "params": {
    "changes": [
      {
        "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/page.qute.html",
        "type": 2
      }
    ]
  }
}
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at com.redhat.qute.ls.commons.ParentProcessWatcher.lambda$apply$0(ParentProcessWatcher.java:148)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 12 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.redhat.qute.parser.template.Template.getProjectUri()" because "template" is null
	at com.redhat.qute.services.ResolvingJavaTypeContext.<init>(ResolvingJavaTypeContext.java:50)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.triggerValidationFor(TemplateFileTextDocumentService.java:395)
	at com.redhat.qute.ls.QuteTextDocumentService.triggerValidationFor(QuteTextDocumentService.java:325)
	at com.redhat.qute.ls.QuteLanguageServer.triggerValidationFor(QuteLanguageServer.java:333)
	at com.redhat.qute.project.QuteProject.validateClosedTemplates(QuteProject.java:152)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.triggerValidationFor(TemplateFileTextDocumentService.java:448)
	at com.redhat.qute.ls.QuteTextDocumentService.triggerValidationFor(QuteTextDocumentService.java:335)
	at com.redhat.qute.ls.QuteLanguageServer.triggerValidationFor(QuteLanguageServer.java:343)
	at com.redhat.qute.project.QuteProjectRegistry.didChangeWatchedFiles(QuteProjectRegistry.java:390)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.didChangeWatchedFiles(TemplateFileTextDocumentService.java:385)
	at com.redhat.qute.ls.QuteTextDocumentService.didChangeWatchedFiles(QuteTextDocumentService.java:320)
	at com.redhat.qute.ls.QuteLanguageServer.didChangeWatchedFiles(QuteLanguageServer.java:317)
	at com.redhat.qute.ls.QuteWorkspaceService.didChangeWatchedFiles(QuteWorkspaceService.java:60)
	... 17 more

[Trace - 15:40:31] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
    "changes": [
        {
            "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/target/classes/templates/page.qute.html",
            "type": 2
        }
    ]
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read QuteClosedTextDocument.loadTemplate and TemplateFileTextDocumentService.triggerValidationFor, then trace QuteProject.validateClosedTemplates after didChangeWatchedFiles. Reproduce by deleting includes/footer.html and saving page.qute.html. Done means missing included templates still produce TemplateNotFound diagnostics without an exception or notification failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.