mission_item_protocol: guard against no master when running commands#1685
Merged
peterbarker merged 1 commit intoMay 16, 2026
Conversation
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>
Contributor
|
Merged, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1678
Running
wp list,fence list, or any other subcommand from these modules before a vehicle is connected hits an unguardedself.master.mav.mission_request_list_send(...)inrequest_list_send()and crashes withAttributeError: 'NoneType' object has no attribute 'mav'.Fix
cmd_wp— added an earlyif self.master is Noneguard 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 everyself.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_rangefrom changealt/changeframe,update_waypointsfrom 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(...); returnpattern matchmavproxy_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 viacmd_wporfetch(), so the entry-level guards cover them without adding redundant checks.idle_taskalready guards (line 305).commands()at line 901 uses a truthy check soself.master is Nonefalls through harmlessly.Test
flake8 clean (
AP_FLAKE8_CLEANhonored). With the patch,mavproxy.py --mapfollowed bywp list/fence list/rally listprintswp: no vehicle connected(etc.) and returns instead of tracing back.