You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The URL from a previous call can accidentally be reused for later, misconfigured, call.
Reproduction:
localcurl=require"plenary.curl"-- 1. Call any method (even `request`) with the URL string as the first argumentcurl.get("localhost", { dry_run=true }) -- { ..., "-X", "GET", "localhost" }-- 2. Call any method (except `request`) with table as the first argument, with `url` key missingcurl.get({ dry_run=true }) -- { ..., "-X", "GET", "localhost" }
Observed behaviour:
The second call uses the URL from the previous call.
Expected behaviour:
The second call should either:
raise an error because the url is missing from the options, or
at least not use the URL from previous call
The error on missing URL could also be better... (Should this be another issue?)
I would expect either an explicit error from the library, or some error from curl itself. (Although I'm not sure if there is any meaningful case where curl could be used without the URL?)
I could see some use case for this behaviour, but I think it should be an explicit API. (The request method is also inconsistent with the others and bit surprising how it may end up ignoring the first argument.)
So, am I correct assuming this is a bug, not a feature?
The text was updated successfully, but these errors were encountered:
The URL from a previous call can accidentally be reused for later, misconfigured, call.
Reproduction:
Observed behaviour:
The second call uses the URL from the previous call.
Expected behaviour:
The second call should either:
url
is missing from the options, orThe error on missing URL could also be better... (Should this be another issue?)
I would expect either an explicit error from the library, or some error from curl itself. (Although I'm not sure if there is any meaningful case where curl could be used without the URL?)
However, now the error happens at
plenary.nvim/lua/plenary/curl.lua
Line 246 in a3e3bc8
parse.url(nil)
returns zero values.Cause:
The
spec
table is shared between all the methods and calls, but theurl
field is not always set. This can lead to unintentional reuse of the field.plenary.nvim/lua/plenary/curl.lua
Lines 325 to 335 in a3e3bc8
I could see some use case for this behaviour, but I think it should be an explicit API. (The
request
method is also inconsistent with the others and bit surprising how it may end up ignoring the first argument.)So, am I correct assuming this is a bug, not a feature?
The text was updated successfully, but these errors were encountered: