Detect statically identifiable repeat fieldnames and fix offending field in 'endpoint show' #1230
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.
I noticed that the "Department" field was repeated and explored two techniques for detecting this automatically.
First, runtime detection in printers -- this works but pays a cost at runtime every time a command runs for something we should catch during development.
Testing with this approach verified that it works and that there are no other duplicates in our record-printed fields (at least, under tests).
Second, detection using our local flake8 plugin, adding a rule against duplicate fieldnames in static lists of field objects.
This detects the only real offending example just as well as the runtime check, and only pays the cost at development time (and it is a small cost at that).
Finally, exploration done, remove the runtime check and actually fix the bug by removing the first of the two duplicates.