STAC.jl icon indicating copy to clipboard operation
STAC.jl copied to clipboard

`length(catalog.items)` fails

Open felixcremer opened this issue 6 months ago • 2 comments

I am trying to explore the Forest Non-Forest data that is available here:

https://geoservice.dlr.de/eoc/ogc/stac/v1/collections/TDM_FNF_50

When I open the parent catalog and open this as a sub collection running length(fnf.items) fails with the following error. I am not entirely sure, whether this is an issue of this package or an issue of the STAC catalog.

julia> fnfurl = "https://geoservice.dlr.de/eoc/ogc/stac/v1/"
"https://geoservice.dlr.de/eoc/ogc/stac/v1/"

julia> fnfcat = STAC.Catalog(fnfurl);

julia> fnf = fnfcat["TDM_FNF_50"];
julia> length(fnf.items)
ERROR: TaskFailedException
Stacktrace:
  [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
    @ Base ./task.jl:958
  [2] wait()
    @ Base ./task.jl:1022
  [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
    @ Base ./condition.jl:130
  [4] wait
    @ ./condition.jl:125 [inlined]
  [5] take_unbuffered(c::Channel{String})
    @ Base ./channels.jl:510
  [6] take!
    @ ./channels.jl:487 [inlined]
  [7] iterate(c::Channel{String}, state::Nothing)
    @ Base ./channels.jl:629
  [8] _collect(cont::UnitRange{Int64}, itr::Channel{String}, ::Base.HasEltype, isz::Base.SizeUnknown)
    @ Base ./array.jl:729
  [9] collect
    @ ./array.jl:716 [inlined]
 [10] length(odw::STAC.OrderedDictWrapper{STAC.Catalog, typeof(STAC.item), typeof(STAC.items_ids)})
    @ STAC ~/Documents/STACCube.jl/dev/STAC/src/utils.jl:71
 [11] top-level scope
    @ REPL[22]:1

    nested task error: TaskFailedException
    Stacktrace:
     [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
       @ Base ./task.jl:958
     [2] wait()
       @ Base ./task.jl:1022
     [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
       @ Base ./condition.jl:130
     [4] wait
       @ ./condition.jl:125 [inlined]
     [5] take_unbuffered(c::Channel{STAC.Item})
       @ Base ./channels.jl:510
     [6] take!
       @ ./channels.jl:487 [inlined]
     [7] iterate(c::Channel{STAC.Item}, state::Nothing)
       @ Base ./channels.jl:629
     [8] (::STAC.var"#32#33"{DataType, STAC.Catalog, Symbol})(c::Channel{String})
       @ STAC ~/Documents/STACCube.jl/dev/STAC/src/catalog.jl:169
     [9] (::Base.var"#739#740"{STAC.var"#32#33"{DataType, STAC.Catalog, Symbol}, Channel{String}})()
       @ Base ./channels.jl:142
    
        nested task error: KeyError: key :method not found
        Stacktrace:
         [1] getindex(h::Dict{Symbol, Int64}, key::Symbol)
           @ Base ./dict.jl:477
         [2] get(obj::JSON3.Object{Base.CodeUnits{UInt8, String}, SubArray{UInt64, 1, Vector{…}, Tuple{…}, true}}, key::Symbol)
           @ JSON3 ~/.julia/packages/JSON3/ntJon/src/JSON3.jl:87
         [3] getindex(obj::JSON3.Object{Base.CodeUnits{UInt8, String}, SubArray{UInt64, 1, Vector{…}, Tuple{…}, true}}, key::Symbol)
           @ JSON3 ~/.julia/packages/JSON3/ntJon/src/JSON3.jl:128
         [4] (::STAC.var"#41#43"{Symbol, Dict{String, Int64}})(c::Channel{STAC.Item})
           @ STAC ~/Documents/STACCube.jl/dev/STAC/src/search.jl:19
         [5] (::Base.var"#739#740"{STAC.var"#41#43"{Symbol, Dict{String, Int64}}, Channel{STAC.Item}})()
           @ Base ./channels.jl:142
Some type information was truncated. Use `show(err)` to see complete types.

felixcremer avatar Jul 09 '25 13:07 felixcremer

This comes from the fact, that the next pages do not give a method in the HTTP result and therefore the check for next_request[:method] fails. I think I fixed it by converting this check to get(next_request, :method, "NotGiven")

I am soon going to open a PR for that.

felixcremer avatar Jul 09 '25 13:07 felixcremer

Thank you for looking into this issue! I have updated the search function following your suggestion!

Alexander-Barth avatar Jul 15 '25 09:07 Alexander-Barth