puppetlabs / puppet-editor-services

Puppet Language Server for editors
Apache License 2.0
46 stars 21 forks source link

Various parameters do not show up for certain modules #349

Closed fgimian closed 11 months ago

fgimian commented 1 year ago

What Versions are you running?

OS Version: Ubuntu 20.04 (via Remote SSH extension), host is on Windows 10 Pro VSCode Version: 1.80.0 Puppet Extension Version: Latest stable release and also tested the latest build in CI PDK Version: 3.0.0

What You Are Seeing?

Various parameter seem to be missing from the completion list depending on the module.

image

Parameters such as 'ensure' and 'source' for example.

Here's how service looks:

image

As you can see, it took is missing various parameters.

What is Expected?

I expected to see all possible parameters listed and available via autocomplete.

How Did You Get This To Happen? (Steps to Reproduce)

I built a fresh Ubuntu 20.04 server and installed the Puppet Server as follows:

# Install the Puppet Server.
wget https://apt.puppet.com/puppet8-release-focal.deb
sudo dpkg -i puppet8-release-focal.deb
sudo apt update
sudo apt install puppetserver

# Start the service.
sudo systemctl start puppetserver.service
sudo systemctl enable puppetserver.service

I then installed PDK:

sudo apt install pdk

I changed the ownership of /etc/puppetlabs/code to my user id and created a file under /etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp which is where I attempted to add a file resource.

Output Log

I, [2023-07-10T15:53:42.192332 #6943]  INFO -- : Language Server is v1.3.0
D, [2023-07-10T15:53:42.197059 #6943] DEBUG -- : Loading gems...
I, [2023-07-10T15:53:42.868570 #6943]  INFO -- : Using Puppet v8.1.0
I, [2023-07-10T15:53:42.869296 #6943]  INFO -- : Using Facter v4.4.1
D, [2023-07-10T15:53:42.869824 #6943] DEBUG -- : Detected additional puppet settings []
I, [2023-07-10T15:53:42.876771 #6943]  INFO -- : Initializing settings...
I, [2023-07-10T15:53:42.877544 #6943]  INFO -- : Starting RPC Server...
D, [2023-07-10T15:53:42.879337 #6943] DEBUG -- : Using STDIO Server
D, [2023-07-10T15:53:42.884276 #6943] DEBUG -- : STDIOSRV: Starting STDIO server...
D, [2023-07-10T15:53:42.885064 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":6876,"rootPath":"/etc/puppetlabs/code","rootUri":"file:///etc/puppetlabs/code","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true}}},"trace":"off","workspaceFolders":[{"uri":"file:///etc/puppetlabs/code","name":"code"}]}}
---
D, [2023-07-10T15:53:42.885571 #6943] DEBUG -- : Received initialize method
I, [2023-07-10T15:53:42.886284 #6943]  INFO -- : Loading Default Data via aggregate (Async)...
D, [2023-07-10T15:53:42.887559 #6943] DEBUG -- : SidecarQueue Thread: Running sidecar ["ruby", "/home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/puppet-languageserver-sidecar", "--action", "default_aggregate", "--puppet-version=8.1.0"]
D, [2023-07-10T15:53:42.887948 #6943] DEBUG -- : SidecarQueue Thread: Running sidecar ["ruby", "/home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/puppet-languageserver-sidecar", "--action", "facts", "--puppet-version=8.1.0"]
I, [2023-07-10T15:53:42.888404 #6943]  INFO -- : Loading static data (Async)...
D, [2023-07-10T15:53:42.893221 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-aggregate.json...
D, [2023-07-10T15:53:42.894598 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":1,"hoverProvider":true,"completionProvider":{"resolveProvider":true,"triggerCharacters":[">","$","[","="]},"definitionProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]}}}}
---
D, [2023-07-10T15:53:42.894912 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-boltlib.json...
D, [2023-07-10T15:53:42.896092 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-canary.json...
D, [2023-07-10T15:53:42.896661 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-ctrl.json...
D, [2023-07-10T15:53:42.897253 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-dir.json...
D, [2023-07-10T15:53:42.897728 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-file.json...
D, [2023-07-10T15:53:42.898094 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-log.json...
D, [2023-07-10T15:53:42.898428 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","method":"initialized","params":{}}
---
D, [2023-07-10T15:53:42.898902 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-out.json...
I, [2023-07-10T15:53:42.899101 #6943]  INFO -- : Client has received initialization
D, [2023-07-10T15:53:42.899938 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-prompt.json...
I, [2023-07-10T15:53:42.900025 #6943]  INFO -- : Attempting to dynamically register the workspace/didChangeConfiguration method with id b7b4194e-daf6-4909-8204-eba6e724c4d1
D, [2023-07-10T15:53:42.900577 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"registerOptions":{},"id":"b7b4194e-daf6-4909-8204-eba6e724c4d1","method":"workspace/didChangeConfiguration"}]}}
---
D, [2023-07-10T15:53:42.900713 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-puppet_connect.json...
D, [2023-07-10T15:53:42.901027 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","languageId":"puppet","version":1,"text":"# Class: base\n#\n#\nclass base {\n  service { 'title':\n    \n  }\n}\n"}}}
---
D, [2023-07-10T15:53:42.901492 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-puppetdb_fact.json...
I, [2023-07-10T15:53:42.901900 #6943]  INFO -- : Received textDocument/didOpen notification.
D, [2023-07-10T15:53:42.902018 #6943] DEBUG -- : Importing static data file /home/fots/.vscode-server/extensions/puppet.puppet-vscode-1.4.0/vendor/languageserver/lib/puppet-languageserver/static_data/bolt-system.json...
D, [2023-07-10T15:53:42.902569 #6943] DEBUG -- : Static bolt data returned 59 functions
D, [2023-07-10T15:53:42.902829 #6943] DEBUG -- : Static bolt data returned 9 datatypes
D, [2023-07-10T15:53:42.903141 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":0,"result":null}
---
I, [2023-07-10T15:53:42.903535 #6943]  INFO -- : Succesfully dynamically registered the workspace/didChangeConfiguration method
D, [2023-07-10T15:53:42.904043 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"section":"puppet"}]}}
---
D, [2023-07-10T15:53:42.921681 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","diagnostics":[{"source":"Puppet","range":{"end":{"line":5,"character":4},"start":{"line":5,"character":0}},"code":"trailing_whitespace","severity":1,"message":"trailing whitespace found"},{"source":"Puppet","range":{"end":{"line":4,"character":21},"start":{"line":4,"character":20}},"code":"manifest_whitespace_closing_brace_before","severity":1,"message":"there should be a single space or newline before a closing brace"}]}}
---
D, [2023-07-10T15:53:42.922622 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":1,"result":[{"editorService":{"enable":true,"debugFilePath":"/var/tmp/puppetvscode.log","featureFlags":[],"foldingRange":{"enable":true,"showLastLine":false},"formatOnType":{"enable":false,"maxFileSize":4096},"hover":{"showMetadataInfo":true},"loglevel":"debug","protocol":"stdio","puppet":{"confdir":"","environment":"","modulePath":"","vardir":"","version":""},"tcp":{"address":"","port":0},"timeout":10},"validate":{"resolvePuppetfiles":true},"format":{"enable":true},"installDirectory":"","installType":"auto","notification":{"nodeGraph":"messagebox","puppetResource":"messagebox"},"pdk":{"checkVersion":true},"titleBar":{"pdkNewModule":{"enable":true}}}]}
---
I, [2023-07-10T15:53:42.928324 #6943]  INFO -- : Attempting to dynamically register the textDocument/foldingRange method with id ea78a498-6418-4efd-9184-189714cab186
D, [2023-07-10T15:53:42.929647 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":2,"method":"client/registerCapability","params":{"registrations":[{"registerOptions":{"firstTriggerCharacter":">"},"id":"ea78a498-6418-4efd-9184-189714cab186","method":"textDocument/foldingRange"}]}}
---
D, [2023-07-10T15:53:42.930552 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":2,"result":null}
---
I, [2023-07-10T15:53:42.931069 #6943]  INFO -- : Succesfully dynamically registered the textDocument/foldingRange method
A, [2023-07-10T15:53:43.685780 #6943]   ANY -- : SidecarQueue Thread: Calling sidecar with --action default_aggregate --puppet-version=8.1.0 returned exitcode 0, ruby: warning: shebang line ending with \r may cause problems

D, [2023-07-10T15:53:43.696338 #6943] DEBUG -- : SidecarQueue Thread: default_aggregate returned 39 datatypes
D, [2023-07-10T15:53:43.697259 #6943] DEBUG -- : SidecarQueue Thread: default_aggregate returned 104 functions
D, [2023-07-10T15:53:43.697682 #6943] DEBUG -- : SidecarQueue Thread: default_aggregate returned 14 types
A, [2023-07-10T15:53:43.737776 #6943]   ANY -- : SidecarQueue Thread: Calling sidecar with --action facts --puppet-version=8.1.0 returned exitcode 0, ruby: warning: shebang line ending with \r may cause problems

D, [2023-07-10T15:53:43.738810 #6943] DEBUG -- : SidecarQueue Thread: facts returned 30 items
D, [2023-07-10T15:53:43.902901 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":1,"method":"puppet/getVersion","params":null}
---
D, [2023-07-10T15:53:43.906802 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":1,"result":{"puppetVersion":"8.1.0","facterVersion":"4.4.1","languageServerVersion":"1.3.0","factsLoaded":true,"functionsLoaded":true,"typesLoaded":true,"classesLoaded":true}}
---
D, [2023-07-10T15:53:56.637660 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/manifests/site.pp","languageId":"puppet","version":1,"text":"node 'fotsies-server-1.example.com' {}\n"}}}
---
I, [2023-07-10T15:53:56.638498 #6943]  INFO -- : Received textDocument/didOpen notification.
D, [2023-07-10T15:53:56.642409 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":2,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/manifests/site.pp"}}}
---
D, [2023-07-10T15:53:56.644221 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///etc/puppetlabs/code/environments/production/manifests/site.pp","diagnostics":[]}}
---
D, [2023-07-10T15:53:56.644668 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":2,"result":[]}
---
D, [2023-07-10T15:53:56.924933 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":3,"method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/manifests/site.pp"}}}
---
D, [2023-07-10T15:53:56.925732 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":3,"result":[]}
---
D, [2023-07-10T15:53:57.308828 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":4,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"}}}
---
D, [2023-07-10T15:53:57.310673 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":4,"result":[{"selectionRange":{"end":{"line":7,"character":1},"start":{"line":3,"character":0}},"name":"base","detail":"base","range":{"end":{"line":7,"character":1},"start":{"line":3,"character":0}},"children":[{"selectionRange":{"start":{"line":4,"character":12},"end":{"line":4,"character":19}},"name":"service: 'title'","detail":"service: 'title'","range":{"end":{"line":6,"character":3},"start":{"line":4,"character":2}},"children":[],"kind":6}],"kind":5}]}
---
D, [2023-07-10T15:53:57.605693 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":5,"method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"}}}
---
D, [2023-07-10T15:53:57.608809 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":5,"result":[{"startLine":0,"startCharacter":0,"endLine":2,"endCharacter":1,"kind":"comment"},{"startLine":4,"startCharacter":10,"endLine":6,"endCharacter":3},{"startLine":3,"startCharacter":11,"endLine":7,"endCharacter":1}]}
---
D, [2023-07-10T15:53:59.945421 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","version":2},"contentChanges":[{"text":"# Class: base\n#\n#\nclass base {\n  \n}\n"}]}}
---
I, [2023-07-10T15:53:59.948471 #6943]  INFO -- : Received textDocument/didChange notification.
D, [2023-07-10T15:53:59.956277 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","diagnostics":[{"source":"Puppet","range":{"end":{"line":4,"character":2},"start":{"line":4,"character":0}},"code":"trailing_whitespace","severity":1,"message":"trailing whitespace found"},{"source":"Puppet","range":{"end":{"line":3,"character":13},"start":{"line":3,"character":12}},"code":"manifest_whitespace_closing_brace_before","severity":1,"message":"there should be a single space or newline before a closing brace"}]}}
---
D, [2023-07-10T15:54:00.047105 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":6,"method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"}}}
---
D, [2023-07-10T15:54:00.049855 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":6,"result":[{"startLine":0,"startCharacter":0,"endLine":2,"endCharacter":1,"kind":"comment"},{"startLine":3,"startCharacter":11,"endLine":5,"endCharacter":1}]}
---
D, [2023-07-10T15:54:00.185560 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","version":3},"contentChanges":[{"text":"# Class: base\n#\n#\nclass base {\n  f\n}\n"}]}}
---
I, [2023-07-10T15:54:00.186476 #6943]  INFO -- : Received textDocument/didChange notification.
D, [2023-07-10T15:54:00.187417 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":7,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"},"position":{"line":4,"character":3},"context":{"triggerKind":1}}}
---
D, [2023-07-10T15:54:00.194814 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":7,"result":{"isIncomplete":false,"items":[{"detail":"Keyword","data":{"type":"keyword","name":"require"},"label":"require","kind":14},{"detail":"Keyword","data":{"type":"keyword","name":"contain"},"label":"contain","kind":14},{"detail":"Resource","data":{"type":"resource_type","name":"component"},"label":"component","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"exec"},"label":"exec","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"file"},"label":"file","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"filebucket"},"label":"filebucket","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"group"},"label":"group","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"notify"},"label":"notify","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"package"},"label":"package","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"resources"},"label":"resources","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"schedule"},"label":"schedule","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"service"},"label":"service","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"stage"},"label":"stage","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"tidy"},"label":"tidy","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"user"},"label":"user","kind":9},{"detail":"Resource","data":{"type":"resource_type","name":"whit"},"label":"whit","kind":9}]}}
---
D, [2023-07-10T15:54:00.197228 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","diagnostics":[{"source":"Puppet","range":{"end":{"line":4,"character":4},"start":{"line":4,"character":3}},"severity":1,"message":"Could not parse for environment *root*: This Name has no effect. A Host Class Definition can not end with a value-producing expression without other effect (line: 5, column: 3)"}]}}
---
D, [2023-07-10T15:54:00.216144 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":8,"method":"completionItem/resolve","params":{"label":"file","detail":"Resource","insertTextFormat":1,"kind":9,"data":{"type":"resource_type","name":"file"}}}
---
D, [2023-07-10T15:54:00.217240 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":8,"result":{"detail":"Resource","data":{"type":"resource_type","name":"file"},"insertTextFormat":2,"label":"file","documentation":"Manages files, including their content, ownership, and permissions.\n\nThe `file` type can manage normal files, directories, and symlinks; the\ntype should be specified in the `ensure` attribute.\n\nFile contents can be managed directly with the `content` attribute, or\ndownloaded from a remote source using the `source` attribute; the latter\ncan also be used to recursively serve directories (when the `recurse`\nattribute is set to `true` or `local`). On Windows, note that file\ncontents are managed in binary mode; Puppet never automatically translates\nline endings.\n\n**Autorequires:** If Puppet is managing the user or group that owns a\nfile, the file resource will autorequire them. If Puppet is managing any\nparent directories of a file, the file resource autorequires them.\n\nWarning: Enabling `recurse` on directories containing large numbers of\nfiles slows agent runs. To manage file attributes for many files,\nconsider using alternative methods such as the `chmod_r`, `chown_r`,\n or `recursive_file_permissions` modules from the Forge.","insertText":"file { '${1:title}':\n}","kind":9}}
---
D, [2023-07-10T15:54:00.887920 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","version":7},"contentChanges":[{"text":"# Class: base\n#\n#\nclass base {\n  file { 'title':\n  }\n}\n"}]}}
---
I, [2023-07-10T15:54:00.888950 #6943]  INFO -- : Received textDocument/didChange notification.
D, [2023-07-10T15:54:00.899438 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","diagnostics":[]}}
---
D, [2023-07-10T15:54:00.976320 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":9,"method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"}}}
---
D, [2023-07-10T15:54:00.977633 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":9,"result":[{"startLine":0,"startCharacter":0,"endLine":2,"endCharacter":1,"kind":"comment"},{"startLine":4,"startCharacter":7,"endLine":5,"endCharacter":3},{"startLine":3,"startCharacter":11,"endLine":6,"endCharacter":1}]}
---
D, [2023-07-10T15:54:01.200224 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":10,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"}}}
---
D, [2023-07-10T15:54:01.201973 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":10,"result":[{"selectionRange":{"end":{"line":6,"character":1},"start":{"line":3,"character":0}},"name":"base","detail":"base","range":{"end":{"line":6,"character":1},"start":{"line":3,"character":0}},"children":[{"selectionRange":{"start":{"line":4,"character":9},"end":{"line":4,"character":16}},"name":"file: 'title'","detail":"file: 'title'","range":{"end":{"line":5,"character":3},"start":{"line":4,"character":2}},"children":[],"kind":6}],"kind":5}]}
---
D, [2023-07-10T15:54:03.551439 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","version":8},"contentChanges":[{"text":"# Class: base\n#\n#\nclass base {\n  file { 'title':\n  \n  }\n}\n"}]}}
---
I, [2023-07-10T15:54:03.554027 #6943]  INFO -- : Received textDocument/didChange notification.
D, [2023-07-10T15:54:03.562965 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","diagnostics":[{"source":"Puppet","range":{"end":{"line":5,"character":2},"start":{"line":5,"character":0}},"code":"trailing_whitespace","severity":1,"message":"trailing whitespace found"},{"source":"Puppet","range":{"end":{"line":4,"character":18},"start":{"line":4,"character":17}},"code":"manifest_whitespace_closing_brace_before","severity":1,"message":"there should be a single space or newline before a closing brace"},{"source":"Puppet","range":{"end":{"line":5,"character":2},"start":{"line":5,"character":0}},"code":"strict_indent","severity":2,"message":"indent should be 4 chars and is 2"}]}}
---
D, [2023-07-10T15:54:03.648550 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":11,"method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"}}}
---
D, [2023-07-10T15:54:03.650915 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":11,"result":[{"startLine":0,"startCharacter":0,"endLine":2,"endCharacter":1,"kind":"comment"},{"startLine":4,"startCharacter":7,"endLine":6,"endCharacter":3},{"startLine":3,"startCharacter":11,"endLine":7,"endCharacter":1}]}
---
D, [2023-07-10T15:54:03.905763 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","version":9},"contentChanges":[{"text":"# Class: base\n#\n#\nclass base {\n  file { 'title':\n    \n  }\n}\n"}]}}
---
I, [2023-07-10T15:54:03.907910 #6943]  INFO -- : Received textDocument/didChange notification.
D, [2023-07-10T15:54:03.924108 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp","diagnostics":[{"source":"Puppet","range":{"end":{"line":5,"character":4},"start":{"line":5,"character":0}},"code":"trailing_whitespace","severity":1,"message":"trailing whitespace found"},{"source":"Puppet","range":{"end":{"line":4,"character":18},"start":{"line":4,"character":17}},"code":"manifest_whitespace_closing_brace_before","severity":1,"message":"there should be a single space or newline before a closing brace"}]}}
---
D, [2023-07-10T15:54:03.986310 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":12,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"},"position":{"line":5,"character":4},"context":{"triggerKind":1}}}
---
D, [2023-07-10T15:54:03.988591 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":12,"result":{"isIncomplete":false,"items":[{"detail":"Parameter","data":{"type":"resource_parameter","param":"path","resource_type":"file"},"label":"path","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"backup","resource_type":"file"},"label":"backup","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"recurse","resource_type":"file"},"label":"recurse","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"recurselimit","resource_type":"file"},"label":"recurselimit","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"max_files","resource_type":"file"},"label":"max_files","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"replace","resource_type":"file"},"label":"replace","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"force","resource_type":"file"},"label":"force","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"ignore","resource_type":"file"},"label":"ignore","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"links","resource_type":"file"},"label":"links","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"purge","resource_type":"file"},"label":"purge","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"sourceselect","resource_type":"file"},"label":"sourceselect","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"show_diff","resource_type":"file"},"label":"show_diff","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"staging_location","resource_type":"file"},"label":"staging_location","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"validate_cmd","resource_type":"file"},"label":"validate_cmd","kind":10},{"detail":"Parameter","data":{"type":"resource_parameter","param":"validate_replacement","resource_type":"file"},"label":"validate_replacement","kind":10}]}}
---
D, [2023-07-10T15:54:03.998912 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":13,"method":"completionItem/resolve","params":{"label":"backup","detail":"Parameter","insertTextFormat":1,"kind":10,"data":{"type":"resource_parameter","param":"backup","resource_type":"file"}}}
---
D, [2023-07-10T15:54:03.999769 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":13,"result":{"detail":"Parameter","data":{"type":"resource_parameter","param":"backup","resource_type":"file"},"insertTextFormat":1,"label":"backup","documentation":"Whether (and how) file content should be backed up before being replaced.\nThis attribute works best as a resource default in the site manifest\n(`File { backup => main }`), so it can affect all file resources.\n\n* If set to `false`, file content won't be backed up.\n* If set to a string beginning with `.`, such as `.puppet-bak`, Puppet will\n  use copy the file in the same directory with that value as the extension\n  of the backup. (A value of `true` is a synonym for `.puppet-bak`.)\n* If set to any other string, Puppet will try to back up to a filebucket\n  with that title. Puppet automatically creates a **local** filebucket\n  named `puppet` if one doesn't already exist. See the `filebucket` resource\n  type for more details.\n\nDefault value: `false`\n\nBacking up to a local filebucket isn't particularly useful. If you want\nto make organized use of backups, you will generally want to use the\nprimary Puppet server's filebucket service. This requires declaring a\nfilebucket resource and a resource default for the `backup` attribute\nin site.pp:\n\n    #
/etc/puppetlabs/puppet/manifests/site.pp\n    filebucket { 'main':\n      path   => false,                # This is required for remote filebuckets.\n      server => 'puppet.example.com', # Optional; defaults to the configured primary Puppet server.\n    }\n\n    File { backup => main, }\n\nIf you are using multiple primary servers, you will want to\ncentralize the contents of the filebucket. Either configure your load\nbalancer to direct all filebucket traffic to a single primary server, or use\nsomething like an out-of-band rsync task to synchronize the content on all\nprimary servers.\n\n> **Note**: Enabling and using the backup option, and by extension the\n  filebucket resource, requires appropriate planning and management to ensure\n  that sufficient disk space is available for the file backups. Generally, you\n  can implement this using one of the following two options:\n  - Use a `find` command and `crontab` entry to retain only the last X days\n  of file backups. For example:\n\n  ```\n  find /opt/puppetlabs/server/data/puppetserver/bucket -type f -mtime +45 -atime +45 -print0 | xargs -0 rm\n  ```\n\n  - Restrict the directory to a maximum size after which the oldest items are removed.","insertText":"backup => ","kind":10}}
---
D, [2023-07-10T15:54:04.007035 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":14,"method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"}}}
---
D, [2023-07-10T15:54:04.008349 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":14,"result":[{"startLine":0,"startCharacter":0,"endLine":2,"endCharacter":1,"kind":"comment"},{"startLine":4,"startCharacter":7,"endLine":6,"endCharacter":3},{"startLine":3,"startCharacter":11,"endLine":7,"endCharacter":1}]}
---
D, [2023-07-10T15:54:04.231791 #6943] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":15,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/environments/production/modules/base/manifests/init.pp"}}}
---
D, [2023-07-10T15:54:04.235372 #6943] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":15,"result":[{"selectionRange":{"end":{"line":7,"character":1},"start":{"line":3,"character":0}},"name":"base","detail":"base","range":{"end":{"line":7,"character":1},"start":{"line":3,"character":0}},"children":[{"selectionRange":{"start":{"line":4,"character":9},"end":{"line":4,"character":16}},"name":"file: 'title'","detail":"file: 'title'","range":{"end":{"line":6,"character":3},"start":{"line":4,"character":2}},"children":[],"kind":6}],"kind":5}]}
---
fgimian commented 1 year ago

Just some further info, when hovering over ensure, path and source parameters for the file module, I see the following:

ensure

D, [2023-07-10T17:27:30.161796 #9317] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":15,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/modules/base/manifests/init.pp"},"position":{"line":5,"character":5}}}
---
E, [2023-07-10T17:27:30.164871 #9317] ERROR -- : (textDocument/hover) undefined method `[]' for nil:NilClass
D, [2023-07-10T17:27:30.166414 #9317] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":15,"result":null}
---

path

D, [2023-07-10T17:27:35.017176 #9317] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":16,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/modules/base/manifests/init.pp"},"position":{"line":6,"character":5}}}
---
D, [2023-07-10T17:27:35.021167 #9317] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":16,"result":{"contents":"**path** Parameter\n\nThe path to the file to manage.  Must be fully qualified.\n\nOn Windows, the path should
include the drive letter and should use `/` as\nthe separator character (rather than `\\\\`)."}}
---

source

D, [2023-07-10T17:27:38.196046 #9317] DEBUG -- : --- INBOUND
{"jsonrpc":"2.0","id":17,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///etc/puppetlabs/code/modules/base/manifests/init.pp"},"position":{"line":7,"character":5}}}
---
E, [2023-07-10T17:27:38.199981 #9317] ERROR -- : (textDocument/hover) undefined method `[]' for nil:NilClass
D, [2023-07-10T17:27:38.201193 #9317] DEBUG -- : --- OUTBOUND
{"jsonrpc":"2.0","id":17,"result":null}
---

I've tested this with Puppet 7.x and PDK 2.x just to be sure but I see the same behaviour.

Cheers Fotis

jordanbreen28 commented 1 year ago

hey @fgimian - thanks for raising this! From first glance it does look like a legitimate bug from the language server, so I've went ahead and transferred it to the appropriate repo.

jordanbreen28 commented 11 months ago

hey @fgimian - just wanted to give you a quick update regarding this. So after a bit of digging, I've found out why this is happening. puppet-editor-services compiles its lists of available parameters based on the actual type definitions within the puppet source code, so like here in file for example.

So, you might have gathered that the file resource type has a different structure to most other core types in the link above, and this is where the problem starts to arise. The language server does not know to pull these parameters in as it only looks in the type definition. I'm hoping we can find a solution to this where we can pull in all type parameters, despite the file structure.

I'll keep this thread updated with my findings. Thanks!