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

Unable to deserialise a calendar response, due to unexpected types #251

Open
sammyd opened this issue Dec 26, 2024 · 3 comments
Open

Unable to deserialise a calendar response, due to unexpected types #251

sammyd opened this issue Dec 26, 2024 · 3 comments
Labels
help wanted Standard GitHub label type:bug A broken experience

Comments

@sammyd
Copy link

sammyd commented Dec 26, 2024

Describe the bug

When trying to retrieve the calendars (or any calendar response) a deserialisation error occurs:

[NoMethodError: undefined method `create_from_discriminator_value' for an instance of Hash](http://localhost:3000/calendars#)

This occurs whilst trying to execute this line, parsing the allowedOnlineMeetingProviders field:

https://github.com/microsoftgraph/msgraph-sdk-ruby/blob/main/lib/models/calendar.rb#L235

Expected behavior

It should parse the API response correctly, and not raise an error.

How to reproduce

  1. Create an authenticated ruby client, with access to presumably a minimum of Calendars.Read.
  2. Execute this:
@calendars = client.me.calendars.get.resume

SDK Version

0.22.2

Latest version known to work for scenario above?

No response

Known Workarounds

I've monkey patched this method to just comment out the offending line for now. It's not an acceptable workaround.

Debug output

Click to expand log

20:50:30 web.1  | NoMethodError (Error during deserialization)
20:50:30 web.1  | Caused by: NoMethodError (Error during deserialization)
20:50:30 web.1  | Caused by: NoMethodError (Error during deserialization)
20:50:30 web.1  | Caused by: NoMethodError (undefined method `create_from_discriminator_value' for an instance of Hash)
20:50:30 web.1  |
20:50:30 web.1  | Information for: NoMethodError (Error during deserialization):
20:50:30 web.1  |
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:99:in `rescue in get_object_value'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:93:in `get_object_value'
20:50:30 web.1  | microsoft_kiota_faraday (0.14.0) lib/microsoft_kiota_faraday/faraday_request_adapter.rb:61:in `block in send_async'
20:50:30 web.1  |
20:50:30 web.1  | Information for cause: NoMethodError (Error during deserialization):
20:50:30 web.1  |
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:99:in `rescue in get_object_value'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:93:in `get_object_value'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:89:in `block in get_collection_of_object_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `map'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `get_collection_of_object_values'
20:50:30 web.1  | microsoft_graph (0.22.2) lib/models/calendar_collection_response.rb:34:in `block in get_field_deserializers'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:109:in `block in assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `each'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:96:in `get_object_value'
20:50:30 web.1  | microsoft_kiota_faraday (0.14.0) lib/microsoft_kiota_faraday/faraday_request_adapter.rb:61:in `block in send_async'
20:50:30 web.1  |
20:50:30 web.1  | Information for cause: NoMethodError (Error during deserialization):
20:50:30 web.1  |
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:99:in `rescue in get_object_value'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:93:in `get_object_value'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:89:in `block in get_collection_of_object_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `map'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `get_collection_of_object_values'
20:50:30 web.1  | microsoft_graph (0.22.2) lib/models/calendar.rb:235:in `block in get_field_deserializers'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:109:in `block in assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `each'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:96:in `get_object_value'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:89:in `block in get_collection_of_object_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `map'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `get_collection_of_object_values'
20:50:30 web.1  | microsoft_graph (0.22.2) lib/models/calendar_collection_response.rb:34:in `block in get_field_deserializers'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:109:in `block in assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `each'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:96:in `get_object_value'
20:50:30 web.1  | microsoft_kiota_faraday (0.14.0) lib/microsoft_kiota_faraday/faraday_request_adapter.rb:61:in `block in send_async'

20:50:30 web.1  | Information for cause: NoMethodError (undefined method `create_from_discriminator_value' for an instance of Hash):
20:50:30 web.1  |
20:50:30 web.1  | microsoft_graph (0.22.2) lib/models/calendar.rb:235:in `block (2 levels) in get_field_deserializers'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:95:in `get_object_value'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:89:in `block in get_collection_of_object_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `map'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `get_collection_of_object_values'
20:50:30 web.1  | microsoft_graph (0.22.2) lib/models/calendar.rb:235:in `block in get_field_deserializers'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:109:in `block in assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `each'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:96:in `get_object_value'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:89:in `block in get_collection_of_object_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `map'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:85:in `get_collection_of_object_values'
20:50:30 web.1  | microsoft_graph (0.22.2) lib/models/calendar_collection_response.rb:34:in `block in get_field_deserializers'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:109:in `block in assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `each'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:104:in `assign_field_values'
20:50:30 web.1  | microsoft_kiota_serialization_json (0.9.1) lib/microsoft_kiota_serialization_json/json_parse_node.rb:96:in `get_object_value'
20:50:30 web.1  | microsoft_kiota_faraday (0.14.0) lib/microsoft_kiota_faraday/faraday_request_adapter.rb:61:in `block in send_async'

Configuration

No response

Other information

I'm reasonably confident that this is occurring because this line:

https://github.com/microsoftgraph/msgraph-sdk-ruby/blob/main/lib/models/calendar.rb#L235

"allowedOnlineMeetingProviders" => lambda {|n| @allowed_online_meeting_providers = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::OnlineMeetingProviderType.create_from_discriminator_value(pn) }) },

Is expecting MicrosoftGraph::Models::OnlineMeetingProviderType to be something like a MicrosoftGraph::Models::Entity, but actually, it's just a Hash:

OnlineMeetingProviderType = {
  Unknown: :Unknown,
  SkypeForBusiness: :SkypeForBusiness,
  SkypeForConsumer: :SkypeForConsumer,
  TeamsForBusiness: :TeamsForBusiness,
}

https://github.com/microsoftgraph/msgraph-sdk-ruby/blob/main/lib/models/online_meeting_provider_type.rb

I'm not entirely sure what to do about this, partially because I assume this should actually be a just returning some sort of array of symbols, but more importantly, I believe this gem is auto-generated by Kiota somehow?

I'm happy to put a PR in, but could do with some direction!

Or maybe I'm completely wrong—lemme know!

@sammyd sammyd added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Dec 26, 2024
@baywet
Copy link
Member

baywet commented Dec 27, 2024

Hi @sammyd
Thank you for using kiota and for reaching out.

I'd like to mention that we're operating with a reduced team at the moment, expect delays in responses, thank you for your patience!

I'd also like to share that Ruby as a language for kiota and Microsoft Graph SDKs is currently NOT being funded, meaning that engineering availability to solve issues will be extremely limited even in "regular" periods, if any is available at all.

Even if we receive contributions to address this particular issue, we're not in a position to make releases at this time. See #250 where the continuous integration is failing, because of other generation issues.

You are correct, from a design perspective, this deserialization should be instead calling a parsing method, right now it seems to assume the property is "an object" instead of an enum.

The question I have for you is: do you need this field in the application you're developing?

@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Dec 27, 2024
@sammyd
Copy link
Author

sammyd commented Dec 29, 2024

Thanks for the reply @baywet—I appreciate it, including the context you were able to give about the status of this project.

I didn't need it especially, so my monkey patch to ignore it was working pretty reasonably. However, I then came across a similar problem retrieving events (annoyingly I have forgotten the field, but this was relating to a Double type).

At this point, I decided to cut my losses and implement the relatively small part of the graph API (just relating to calendars and events) as a standalone REST client. This is a shame, but ultimately I think the best approach for me right now.

I had also had to fiddle around a fair amount (implementing the OAuthCustomFlow module methods) to get authentication to work with access/refresh tokens that I'd obtained through the omniauth based login flow that I already had. By this point, the monkey-patching code was approaching the same length of the relatively simple REST client that I needed myself.

I'm using this gem in a different project to access Lists, and it is working pretty well there.

It's a shame it's not being funded, it'd be great to have an easy-to-use gem with access to the whole of microsoft.graph, but I appreciate we can't have everything.

Thanks for your help—let me know if there's anything I can do, otherwise feel free to close this.

ta

sam

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Dec 29, 2024
@baywet
Copy link
Member

baywet commented Dec 30, 2024

Thank you for the additional information.

And for your understanding of the situation.

We'll keep this issue open, for visibility for others and to track the issue in case this project gets funded again.

@baywet baywet added help wanted Standard GitHub label and removed Needs: Attention 👋 labels Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Standard GitHub label type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants