Skip to content

Fix crash in _check_table_difference() when table hashes aren't equal - #4823

Open
gizmoguy wants to merge 3 commits into
faucetsdn:mainfrom
gizmoguy:fix-check-table-difference
Open

Fix crash in _check_table_difference() when table hashes aren't equal#4823
gizmoguy wants to merge 3 commits into
faucetsdn:mainfrom
gizmoguy:fix-check-table-difference

Conversation

@gizmoguy

@gizmoguy gizmoguy commented Jul 1, 2026

Copy link
Copy Markdown
Member

Fixes this crash in _check_table_difference():

  File "/faucet-src/clib/valve_test_lib.py", line 787, in _check_table_difference
    msg="%s != %s\n".join(diff) % (before_hash, after_hash),
        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: not enough arguments for format string

Also as it turns out, hashing of FakeOFTable objects was broken which meant that _check_table_difference() would not always detect a difference between two different table states. The hash was created based on a frozenset of a string:

return hash(frozenset(str(self.tables)))

This effectively just counted unique characters in the string representation of a table, and only if there was a new character present in one of the table states would a different hash be calculated.

Also made a few formatting improvements, firstly table_state() was modified to return the prettified representation of table state which matches the format that _check_table_difference() uses for diffing. Secondly, the order in which flowmods are printed for a table is now sorted by priority then by match.

@gizmoguy
gizmoguy marked this pull request as draft July 2, 2026 02:16
@gizmoguy
gizmoguy force-pushed the fix-check-table-difference branch 5 times, most recently from 889a02f to 6b0602e Compare July 8, 2026 02:04
@gizmoguy
gizmoguy marked this pull request as ready for review July 8, 2026 02:27
@gizmoguy
gizmoguy force-pushed the fix-check-table-difference branch from 6b0602e to d36e58b Compare July 8, 2026 02:32
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.

1 participant