ArduPilot / ArduPilot/pymavlink
Field name clash in some MAVLink messages
- Dominant language
- Python
- Stars
- 728
- Forks
- 739
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 7
Description
[In `mavgen_python.py`](https://github.com/ArduPilot/pymavlink/blob/master/generator/mavgen_python.py#L293), all generated MAVLink message types have two class attributes, `id` and `name`, expressing the MAVLink message type.
However, these class attributes clash with the MAVLink messages with fields called `id` and `name`!
Indeed:
1) `LOG_ENTRY`, `LOG_REQUEST_DATA`, `LOG_DATA`, `DISTANCE_SENSOR`, `BATTERY_STATUS`, `COLLISION` have an `id` field;
2) `DEBUG_VECT`, `NAMED_VALUE_FLOAT`, `NAMED_VALUE_INT`, `UAVCAN_NODE_INFO`, `DEBUG_FLOAT_ARRAY` have a `name` field.
This name clash can cause problems in code depending on the semantics of the `name` and `id` attribute. Example:
```python
>>> from pymavlink.dialects.v20.common import MAVLink_log_entry_message
>>> MAVLink_log_entry_message.name
'LOG_ENTRY'
>>> MAVLink_log_entry_message.id
118
>>> MAVLink_log_entry_message(id=70, num_logs=2, last_log_num=2, time_utc=1000, size=1024).id
70
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in generator/mavgen_python.py around line 293 and inspect how generated message classes expose the MAVLink type metadata and fields. Check the listed messages with id or name fields, then verify generated classes preserve both the metadata and field values without collisions across the affected dialects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100