jellydn / hurl.nvim

Hurl.nvim is a Neovim plugin designed to run HTTP requests directly from `.hurl` files. Elevate your API development workflow by executing and viewing responses without leaving your editor.
https://gyazo.com/19492e8b5366cec3f22d5fd97a63f37a
MIT License
129 stars 14 forks source link

Error using env files #142

Closed phelipe closed 4 months ago

phelipe commented 4 months ago

Details

Following the docs, the plugin should work with the vars.env file and get the variable values, but I always get an error. Below are pieces of information to try to reproduce the problem. Am I doing something wrong or is this a bug?

plugin config

return {
  'jellydn/hurl.nvim',
  dependencies = {
    'MunifTanjim/nui.nvim',
    'nvim-treesitter/nvim-treesitter',
  },
  ft = 'hurl',
  opts = {
    -- Show debugging info
    debug = false,
    -- Show notification on run
    show_notification = false,
    -- Show response in popup or split
    mode = 'split',
    -- Default formatter
    formatters = {
      json = { 'jq' }, -- Make sure you have install jq in your system, e.g: brew install jq
      html = {
        'prettier', -- Make sure you have install prettier in your system, e.g: npm install -g prettier
        '--parser',
        'html',
      },
    },
  },
  keys = {
    -- Run API request
    { '<leader>rr', '<cmd>HurlRunnerAt<CR>', desc = '[R]un Api [R]equest' },
  },
}

plugin version

hurl.nvim 
  url    https://github.com/jellydn/hurl.nvim
  branch main
  commit 2531f2a
  readme README.md
  help   |hurl.nvim.txt|
  ft     hurl
  keys   <leader>rr

hurl file

POST {{API_HOST}}/v1/login

vars.env file

API_HOST = "http://localhost:3001"

output of HurlRunnerAt

  || error: Undefined variable
   --> /home/phelipe/.cache/nvim/6456-1710854193.hurl|1| 8
   ||    |
   ||  1 | POST {{API_HOST}}/v1/login
   ||    |        ^^^^^^^^ you must set the variable API_HOST
Checklist - [X] Modify `lua/hurl/main.lua` ✓ https://github.com/jellydn/hurl.nvim/commit/4fad53879aad1f7b760298bf37316a0a6646fb94 [Edit](https://github.com/jellydn/hurl.nvim/edit/sweep/error_using_env_files/lua/hurl/main.lua) - [X] Running GitHub Actions for `lua/hurl/main.lua` ✗ [Edit](https://github.com/jellydn/hurl.nvim/edit/sweep/error_using_env_files/lua/hurl/main.lua)
sweep-ai[bot] commented 4 months ago

🚀 Here's the PR! #143

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 69845c665b)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/jellydn/hurl.nvim/blob/2531f2a11891ab28097edd6762116e78a26fed52/README.md#L71-L119 https://github.com/jellydn/hurl.nvim/blob/2531f2a11891ab28097edd6762116e78a26fed52/lua/hurl/main.lua#L11-L59 https://github.com/jellydn/hurl.nvim/blob/2531f2a11891ab28097edd6762116e78a26fed52/lua/hurl/main.lua#L167-L199 https://github.com/jellydn/hurl.nvim/blob/2531f2a11891ab28097edd6762116e78a26fed52/lua/hurl/init.lua#L1-L44 https://github.com/jellydn/hurl.nvim/blob/2531f2a11891ab28097edd6762116e78a26fed52/lua/hurl/utils.lua#L1-L29

Step 2: ⌨️ Coding

--- 
+++ 
@@ -56,6 +56,7 @@
   table.sort(files, function(a, b)
     return #a.path > #b.path
   end)
+  utils.log_info('hurl: Constructed paths for ENV files: ' .. vim.inspect(files))
   return files
 end

@@ -210,7 +211,8 @@
   local cmd = vim.list_extend({ 'hurl', '-i', '--no-color' }, opts)
   response = {}

-  utils.log_info('hurl: running command' .. vim.inspect(cmd))
+  utils.log_info('hurl: opts parameter values: ' .. vim.inspect(opts))
+utils.log_info('hurl: running command' .. vim.inspect(cmd))

   vim.fn.jobstart(cmd, {
     on_stdout = callback or on_output,

Ran GitHub Actions for 4fad53879aad1f7b760298bf37316a0a6646fb94:
• pandoc to vimdoc:
• lint:
• Run Test:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/error_using_env_files.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.

jellydn commented 4 months ago

You have an invalid value on your .env file.

Please change to

API_HOST=http://localhost:3001