Skip to content

juniper verify crashes with AttributeError when host's current cloud has no active assignment #751

Closed

Description

@kambiz-aghaiepour

Scenario

Fresh QUADS 3.0.x installation:

  1. Define hosts in the spare pool (e.g. cloud01), add interfaces (em1/em2) with switch_ip/switch_port on a Juniper switch.
  2. Create an assignment/schedule for another cloud (e.g. cloud02).
  3. Before the first move completes (host still in cloud01), run:
    quads --verify-switch-conf --host <hostname> --change

What happens

juniper.verify() resolves the host's current cloud and calls get_active_cloud_assignment("cloud01"), which returns None (no active assignment on the spare pool). For a fresh switch port (no VLAN membership yet), parsing show configuration vlans | display set | match <port>.0 raises IndexError, and the except block reaches the unguarded if not _assignment.vlan: (src/quads/plugins/builtin/switches/juniper.py, ~line 267):

AttributeError: 'NoneType' object has no attribute 'vlan'

The CLI exits with an error for every host, so on a new installation the very first --verify-switch-conf validation fails.

Expected behavior

Never crash. When there is no active assignment for the host's current cloud, warn/skip ("no active assignment for cloud X, cannot verify") and return False, or proceed with derived VLAN values and warnings.

Suggested fix

Guard the None assignment:

-                            if not _assignment.vlan:
+                            if _assignment and not _assignment.vlan:

Notes

  • Scope: manual CLI path (--host, or --cloud of a cloud without an active assignment).
  • The automated --validate-env path is not affected: by then the host is in the target cloud and an active assignment exists.
  • Reproduced on quads 3.0.2 (development branch, build 20261012), juniper plugin enabled.

Activity

  1. ttlogan commented on Oct 18, 2026

    @ttlogan
    Contributor

    Confirmed on development. src/quads/plugins/builtin/switches/juniper.py:267 in the else branch still evaluates _assignment.vlan unguarded, so when get_active_cloud_assignment() returns None you get exactly 'NoneType' object has no attribute 'vlan'. The _assignment and _assignment.vlan guard is already on the if-branch at line 258 but not this one; your if _assignment and not _assignment.vlan fix is right.

    This is the same crash as #740 (same line, same fix path). Worth consolidating one of the two. I'll circle back.

  2. added 2 commits that reference this issue on Oct 19, 2026
    5b03ff7
    ca2082e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions