rest.nvim icon indicating copy to clipboard operation
rest.nvim copied to clipboard

Unable to handle env variables in form params

Open hsanson opened this issue 1 year ago • 0 comments

Following test:

POST {{HOST}}/realms/dev/protocol/openid-connect/auth
Content-Type: application/x-www-form-urlencoded

param1={{value1}}&param2=value2&param3=value3

fails with:

[rest.nvim] ERROR: The tree-sitter node at the range [0:0 - 3:7] has a syntax error and cannot be parsed                                                                                              
Error executing Lua callback: ...jin/Projects/vim/rest.nvim/lua/rest-nvim/parser/init.lua:143: attempt to index local 'document_node' (a nil value)                                                         
stack traceback:                                                                                                                                                                                            
        ...jin/Projects/vim/rest.nvim/lua/rest-nvim/parser/init.lua:143: in function 'traverse_variables'                                                                                                   
        ...jin/Projects/vim/rest.nvim/lua/rest-nvim/parser/init.lua:436: in function 'parse'                                                                                                                
        ...yujin/Projects/vim/rest.nvim/lua/rest-nvim/functions.lua:61: in function 'exec'                                                                                                                  
        .../Projects/vim/rest.nvim/lua/rest-nvim/commands.lua:44: in function 'impl'                                                                                                                  
        .../Projects/vim/rest.nvim/lua/rest-nvim/commands.lua:182: in function <.../Projects/vim/rest.nvim/lua/rest-nvim/commands.lua:165>  j

Seems tree-sitter is unable to parse the form params as seen in Tree-sitter inspec:

(document ; [0, 0] - [4, 0]
  (request ; [0, 0] - [3, 7]
    (method) ; [0, 0] - [0, 4]
    (target_url ; [0, 5] - [0, 53]
      (variable ; [0, 5] - [0, 13]
        name: (identifier)) ; [0, 7] - [0, 11]
      (path ; [0, 13] - [0, 53]
        (identifier) ; [0, 14] - [0, 20]
        (identifier) ; [0, 21] - [0, 24]
        (identifier) ; [0, 25] - [0, 33]
        (identifier) ; [0, 34] - [0, 48]
        (identifier))) ; [0, 49] - [0, 53]
    (header ; [1, 0] - [3, 0]
      name: (name) ; [1, 0] - [1, 12]
      value: (value)) ; [1, 13] - [3, 0]
    (form_data ; [3, 0] - [3, 7]
      name: (identifier) ; [3, 0] - [3, 6]
      value: (value))) ; [3, 7] - [3, 7]
  (variable ; [3, 7] - [3, 17]
    name: (identifier)) ; [3, 9] - [3, 15]
  (ERROR ; [3, 17] - [3, 45]
    (identifier) ; [3, 18] - [3, 24]
    (identifier) ; [3, 25] - [3, 31]
    (identifier) ; [3, 32] - [3, 38]
    (identifier))) ; [3, 39] - [3, 45]

hsanson avatar Mar 21 '24 04:03 hsanson