Different Errors on CI and local machine

I’m encountering an issue with CI on github. If I define

julia> foo(x) = nothing 
foo (generic function with 1 method)

and do a @test_throws with it, I would expect it to throw a MethodError like here

julia> foo(; x = 1)
ERROR: MethodError: no method matching foo(; x=1)
Closest candidates are:
  foo(::Any) at REPL[1]:1 got unsupported keyword argument "x"
Stacktrace:
 [1] top-level scope
   @ REPL[4]

but it seems to throw an ArgumentError instead.
The same issue happens for 1.6.6 and 1.7.3 on CI (throws ArgumentError instead of MethodError). On my local machine running 1.7.3 it always throws a MethodError.

At the current stage, I would consider this a bug but I’m at a complete loss about why it’s happening. Any ideas from the community about what might be the issue here?

In the meantime I’ve worked around it with

if get(ENV, "CI", nothing) == "true"
    @test_throws ArgumentError foo(; x=1)
else
    @test_throws MethodError foo(; x=1)
end

and while it’s nice and explicit about the source of the problem (i.e. the CI environment), it’s not really a long-term solution for the problem.

Thanks in advance and best wishes

Since somebody asked for the CI logs over on Slack, this is one of them where the bug still happened (before I’ve added the CI ENV workaround described above). There isn’t much too see in there to be quite honest. The test that failed looked almost exactly like the one from the previous post.

To debug issues in GitHub Actions: GitHub - mxschmitt/action-tmate: Debug your GitHub Actions via SSH by using tmate to get access to the runner system itself.

It is the same error locally and on CI (ArgumentError). I think the example posted above (with foo) is not what is run on CI. On CI and locally the foo example gives a MethodError for me. If this was not the case for you, could you please provide the CI log where the foo example yields an ArgumentError?

I think what is happening is that the module defines a method

osmplot(...; args...)

thus slurping all the keyword arguments. In the test, there is the call

@test_throws ... osmplot(;osm)

which is lowered to

osmplot(;osm = osm)

Since there is an osm variable bound, this is passed on as a keyword argument, but the osmplot function is not able to handle it, throwing an ArgumentError.

1 Like