microsoft / microsoft/kiota-ruby
Request body is an empty hash
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 5
- Forks
- 8
- Avg merge
- 11h 9m
- Merged PRs (30d)
- 24
Description
When constructing a serialized request body, the body is empty because of these lines here:
writer = request_adapter.get_serialization_writer_factory().get_serialization_writer(content_type)
@headers.try_add(@@content_type_header, content_type)
if values != nil && values.kind_of?(Array)
writer.write_collection_of_object_values(nil, values)
else
writer.write_object_value(nil, values);
end
this.content = writer.get_serialized_content();
The calls to writer.write_collection_of_object_values and writer.write_object_value with a nil key will return a new writer object, thus this.content = writer.get_serialized_content(); will be empty because it doesn't get written to the original writer.
The new writer objects are constructed here:
def write_object_value(key, value)
if value
if !key
temp = JsonSerializationWriter.new()
value.serialize(temp)
return temp
end
begin
temp = JsonSerializationWriter.new()
value.serialize(temp)
@writer[key] = temp.writer
rescue StandardError => e
raise e.class, "no key or value included in write_boolean_value(key, value)"
end
end
end
and here:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/microsoft_kiota_abstractions/request_information.rb around lines 94-107, then inspect the referenced write_object_value and write_collection_of_object_values methods in the JSON serialization writer. Reproduce the request-body construction and verify that serialized object and collection values are retained in the final content rather than producing an empty body.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100