Skip to content

mission_item_protocol: guard against no master when running commands#1685

Merged
peterbarker merged 1 commit into
ArduPilot:masterfrom
evanofficial:fix-mission-item-protocol-no-master-guard
May 16, 2026
Merged

mission_item_protocol: guard against no master when running commands#1685
peterbarker merged 1 commit into
ArduPilot:masterfrom
evanofficial:fix-mission-item-protocol-no-master-guard

Conversation

@evanofficial

Copy link
Copy Markdown
Contributor

Fixes #1678

Running wp list, fence list, or any other subcommand from these modules before a vehicle is connected hits an unguarded self.master.mav.mission_request_list_send(...) in request_list_send() and crashes with AttributeError: 'NoneType' object has no attribute 'mav'.

Fix

  • cmd_wp — added an early if self.master is None guard at the single entry point that dispatches every subcommand (list, clear, load, save, move, movemulti, changealt, changeframe, remove, update, param, status, ftp, ftpload, …). This protects every self.master.mav.* callsite inside the helper methods those subcommands reach (e.g. cmd_clear -> mission_clear_all_send, cmd_load -> send_all_items, cmd_move/cmd_movemulti -> send_single_waypoint, change_mission_item_range from changealt/changeframe, update_waypoints from cmd_update).
  • fetch() — guarded too, since the docstring marks it as public for other modules to call.
  • request_list_send() — guarded as defense-in-depth (this is the exact frame in the traceback).

Message style and if self.master is None: print(...); return pattern match mavproxy_mode.py / mavproxy_ftp.py.

Audit notes

Other self.master.mav.* references in this class (lines 437, 467, 515, 591, 683, 721, 842) live in internal helpers (send_single_waypoint, send_all_items, update_waypoints, change_mission_item_range, cmd_clear, etc.) that are only reachable via cmd_wp or fetch(), so the entry-level guards cover them without adding redundant checks. idle_task already guards (line 305). commands() at line 901 uses a truthy check so self.master is None falls through harmlessly.

Test

flake8 clean (AP_FLAKE8_CLEAN honored). With the patch, mavproxy.py --map followed by wp list / fence list / rally list prints wp: no vehicle connected (etc.) and returns instead of tracing back.

Running 'wp list', 'fence list' or other commands before a vehicle is connected dereferenced self.master in request_list_send, raising AttributeError: 'NoneType' object has no attribute 'mav'.

Add a no-master guard at the top of cmd_wp (the single entry point for all wp/fence/rally subcommands) plus defensive guards in fetch() and request_list_send(), which are documented as public for other modules.

Fixes ArduPilot#1678

Signed-off-by: Evan Sarkar <evan.official666@gmail.com>

@peterbarker peterbarker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@peterbarker peterbarker merged commit c5879c9 into ArduPilot:master May 16, 2026
2 checks passed
@peterbarker

Copy link
Copy Markdown
Contributor

Merged, thanks!

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

Successfully merging this pull request may close these issues.

mission_item_protocol: 'NoneType' object has no attribute 'mav'

2 participants