Skip to content

Commit 9223ae0

Browse files
committed
fix: handle empty JULIAHUB_PROJECT_UUID var correctly
1 parent 107edaf commit 9223ae0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/authentication.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,12 @@ _authentication(server::AbstractString; kwargs...) = _authentication(URIs.URI(se
506506
function _juliahub_project(
507507
project::Union{AbstractString, UUIDs.UUID, Nothing, Missing}
508508
)::Union{UUID, Nothing}
509-
project = coalesce(
510-
project,
511-
get(ENV, "JULIAHUB_PROJECT_UUID", nothing),
512-
)
509+
project_env = get(ENV, "JULIAHUB_PROJECT_UUID", "")
510+
if isempty(project_env)
511+
project_env = nothing
512+
end
513+
project = coalesce(project, project_env)
514+
513515
if isnothing(project)
514516
return nothing
515517
elseif isa(project, UUIDs.UUID)

test/authentication.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
@test JuliaHub._juliahub_project(nothing) === nothing
88
@test JuliaHub._juliahub_project(missing) === nothing
99
end
10+
withenv("JULIAHUB_PROJECT_UUID" => "") do
11+
@test JuliaHub._juliahub_project(uuid1) == UUIDs.UUID(uuid1)
12+
@test_throws ArgumentError JuliaHub._juliahub_project("invalid")
13+
@test_throws ArgumentError JuliaHub._juliahub_project("")
14+
@test JuliaHub._juliahub_project(nothing) === nothing
15+
@test JuliaHub._juliahub_project(missing) === nothing
16+
end
1017
withenv("JULIAHUB_PROJECT_UUID" => uuid1) do
1118
@test JuliaHub._juliahub_project(uuid2) == UUIDs.UUID(uuid2)
1219
@test_throws ArgumentError JuliaHub._juliahub_project("invalid")

0 commit comments

Comments
 (0)