Skip to content

Conversation

@sirosen
Copy link
Member

@sirosen sirosen commented Dec 30, 2025

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.

In the RecordPrinter only, emit a warning when duplicate field names are
used. This causes tests for `endpoint show` to fail because `Department`
is duplicated.
We can detect repeated fieldnames statically when field lists are fully
static. Some minimal assumptions are necessary, primarily that a field
list is a list of calls to `Field()` and that `Field()` means what we
think it does and is always imported under a FromImport.

This fails on the same case which is caught by runtime testing, namely
endpoint show.
Now that this is implemented in flake8, and there are no dynamic cases
which were found with this test which the flake8 lint misses, we do not
need to pay a runtime penalty for this enforcement. Remove the check.
Remove the copy of the field which appears higher up. It now only appears
adjacent to 'Organization', a semantically similar field.
@sirosen sirosen merged commit 072d9c9 into globus:main Dec 30, 2025
6 checks passed
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.

2 participants