gazebosim / gazebosim/sdformat
Parser treats missing required elements inconsistently
- Dominant language
- C++
- Stars
- 216
- Forks
- 125
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 14
Description
First noticed in https://github.com/osrf/sdformat/pull/389#discussion_r533927085:
> Do required fields need defaults? When would the default be used?
> After writing that comment, I saw below that leaving this element out is supposed to still go through, but generates an error... I haven't looked, but is this kind of behaviour documented?
In researching how to respond to this comment I found some inconsistent code (code links from 10.0.0)
* Near the beginning of [readXml() in parser.cc](https://github.com/osrf/sdformat/blob/sdformat10_10.0.0/src/parser.cc#L826-L838), there is a block of code that looks like it fails hard whenever a required element is missing
* Later in the function ([parser.cc:1131-1156](https://github.com/osrf/sdformat/blob/sdformat10_10.0.0/src/parser.cc#L1131-L1156)), there is code that generates errors if any required child elements are missing, but only for joints that aren't of type `ball`! This seems to apply to `//joint/parent` and `//joint/child`. But for anything else, required elements are simply inserted with default values and no error message.
I'll try to make examples that illustrate the different types of behavior here.
Contributor guide
Research direction
Start with readXml() in src/parser.cc, especially the required-element handling near lines 826-838 and 1131-1156. Create examples covering missing required elements, including joint parent and child fields and ball joints, then compare the observed behavior with the intended semantics and add regression coverage once the behavior is decided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100