Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential bug when using wildcard in API filter functionality #65

Open
jonalm opened this issue Dec 6, 2023 · 1 comment
Open

Potential bug when using wildcard in API filter functionality #65

jonalm opened this issue Dec 6, 2023 · 1 comment

Comments

@jonalm
Copy link
Contributor

jonalm commented Dec 6, 2023

I run into an error in the code generated by OpenAPI.jl. The API I'm trying to use accepts a "returning" input string (https://docs.benchling.com/docs/getting-started-1#returning-query-parameter) which is a comma separated list of (potentially nested) return values (e.g. "a.b.c"), which can be used to limit the returning payload. This keyword accepts a wildcard to return all values at that level, but when I use the wildcard I get an error.

I don't know where to start debugging this as the code is autogenerated by OpenAPI. Moreover, the API needs authentication so it is hard to cook up a reproducible example.

Here is the auto generated code https://github.com/jonalm/BenchlingRestApi.jl

And this line https://github.com/jonalm/BenchlingRestApi.jl/blob/0294435467c1d57124d2d85956d383839fc3dd21/codegen/src/models/model_WellOrInaccessibleResource.jl#L17 errors:

ERROR: KeyError: key "resourceType" not found

The following code triggers the error

api_return, http_resp = get_plate(
    PlatesApi(client), 
    arrayspecsubplateid,
    returning="wells.*.webURL" # should limit the payload
)
ERROR: KeyError: key "resourceType" not found
Stacktrace:
  [1] getindex
    @ ./dict.jl:498 [inlined]
  [2] property_type(::Type{BioMe.Benchling.RestApi.WellOrInaccessibleResource}, name::Symbol, json::Dict{String, Any})
    @ BioMe.Benchling.RestApi ~/dev/BioMe.jl/src/Benchling/RestApi/src/models/model_WellOrInaccessibleResource.jl:17
  [3] from_json(o::BioMe.Benchling.RestApi.WellOrInaccessibleResource, name::Symbol, json::Dict{String, Any})
    @ OpenAPI ~/.julia/packages/OpenAPI/p5UeR/src/json.jl:64
  [4] from_json
    @ OpenAPI ~/.julia/packages/OpenAPI/p5UeR/src/json.jl:46 [inlined]
  [5] from_json
    @ OpenAPI ~/.julia/packages/OpenAPI/p5UeR/src/json.jl:40 [inlined]
  [6] convert
    @ ~/.julia/packages/OpenAPI/p5UeR/src/client.jl:712 [inlined]
  [7] setindex!(h::Dict{String, BioMe.Benchling.RestApi.WellOrInaccessibleResource}, v0::Dict{String, Any}, key::String)
    @ Base ./dict.jl:376
  [8] Dict{String, BioMe.Benchling.RestApi.WellOrInaccessibleResource}(kv::Dict{String, Any})
    @ Base ./dict.jl:84
  [9] convert
    @ Base ./abstractdict.jl:568 [inlined]
 [10] from_json
    @ OpenAPI ~/.julia/packages/OpenAPI/p5UeR/src/json.jl:41 [inlined]
 [11] from_json(::Type{Union{Nothing, Dict{…}}}, json::Dict{String, Any})
    @ OpenAPI ~/.julia/packages/OpenAPI/p5UeR/src/json.jl:39
 [12] from_json(o::BioMe.Benchling.RestApi.Plate, name::Symbol, json::Dict{String, Any})
    @ OpenAPI ~/.julia/packages/OpenAPI/p5UeR/src/json.jl:65
 [13] from_json(o::BioMe.Benchling.RestApi.Plate, json::Dict{String, Any})
    @ OpenAPI ~/.julia/packages/OpenAPI/p5UeR/src/json.jl:58
 [14] from_json(o::T, json::Dict{String, Any}) where T<:OpenAPI.APIModel
    @ OpenAPI ~/.julia/packages/OpenAPI/p5UeR/src/json.jl:40 [inlined]
 [15] response
    @ ~/.julia/packages/OpenAPI/p5UeR/src/client.jl:422 [inlined]
 [16] response(::Type{BioMe.Benchling.RestApi.Plate}, is_json::Bool, body::Vector{UInt8})
    @ OpenAPI.Clients ~/.julia/packages/OpenAPI/p5UeR/src/client.jl:411
 [17] response(::Type{BioMe.Benchling.RestApi.Plate}, resp::Downloads.Response, body::Vector{UInt8})
    @ OpenAPI.Clients ~/.julia/packages/OpenAPI/p5UeR/src/client.jl:406
 [18] exec(ctx::OpenAPI.Clients.Ctx, stream_to::Nothing)
    @ OpenAPI.Clients ~/.julia/packages/OpenAPI/p5UeR/src/client.jl:628
 [19] exec
    @ OpenAPI.Clients ~/.julia/packages/OpenAPI/p5UeR/src/client.jl:608 [inlined]
 [20] #get_plate#1549
    @ BioMe.Benchling.RestApi ~/dev/BioMe.jl/src/Benchling/RestApi/src/apis/api_PlatesApi.jl:143 [inlined]
 [21] top-level scope
    @ ~/dev/BioMe.jl/scratch/scratch3.jl:77
Some type information was truncated. Use `show(err)` to see complete types.
@tanmaykm
Copy link
Member

tanmaykm commented Dec 7, 2023

Looks like the client received a response that should have contained an instalce of WellOrInaccessibleResource. That is actually defined to be a type that is oneOf Well or InaccessibleResource. It is specified that whether what was received is a Well or a InaccessibleResource is to be determined by the value of resourceType. But looks like the resourceType key was not found in the JSON that was received.

So the error could be because of the server not responding with the correct data. The first step to debug would be to see what the server responded with. One way to do that may be setting the verbose kwarg while creating the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants