Fix HERD.get_object_entities(attribute=...) to mirror add_ref(attribute=...)#1504
Merged
Conversation
get_object_entities resolved the attribute argument with container[attribute] and a default relative_path, while add_ref routes through _validate_object, which stores non-DataType attributes under a computed relative_path. As a result a reference added with an attribute could not be retrieved with the same attribute (KeyError/TypeError for non-DataType attributes). _validate_object now takes a create flag, and get_object_entities reuses it with create=False so both methods resolve the attribute identically. Add a regression test for the non-DataType attribute case. Fixes #1501. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1504 +/- ##
=======================================
Coverage 93.24% 93.24%
=======================================
Files 41 41
Lines 10217 10217
Branches 2107 2107
=======================================
Hits 9527 9527
Misses 415 415
Partials 275 275 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
oruebel
reviewed
Jun 23, 2026
oruebel
reviewed
Jun 23, 2026
oruebel
reviewed
Jun 23, 2026
oruebel
reviewed
Jun 23, 2026
oruebel
reviewed
Jun 23, 2026
oruebel
requested changes
Jun 23, 2026
oruebel
left a comment
Contributor
There was a problem hiding this comment.
I added some suggestions to help clarify the usage of _check_object_field and fix what I believe is a bug in get_key
…tities-attribute # Conflicts: # CHANGELOG.md
…_key Apply oruebel's review feedback on #1504: - Flip the `create` default to False on `_check_object_field` and `_validate_object`; only `add_ref` passes `create=True`. This fixes `get_key`, which previously relied on the implicit create and would fail on the missing `idx` of a not-yet-added object; it now raises a clear "Object not in Object Table." ValueError. - Add docstrings to `_validate_object` and a `doc` to the `create` docval argument, and rewrite the `_check_object_field` docstring to describe the actual return/raise behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5 tasks
oruebel
approved these changes
Jun 24, 2026
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.
Motivation
Fixes #1501.
HERD.add_ref(container=..., attribute=...)andHERD.get_object_entities(container=..., attribute=...)resolved theattributeargument differently, so a reference added with anattributecould not be read back with the sameattribute:add_refroutes through_validate_object, which for a non-DataType attribute (e.g.DynamicTable.description) stores the parent container under a computedrelative_path.get_object_entitiesinstead didcontainer[attribute]with the defaultrelative_path='', which raisesKeyError(orTypeErrorfor containers without__getitem__) for non-DataType attributes.Solution
_validate_objectnow takes acreateflag and threads it to its_check_object_fieldcalls.get_object_entitiesreuses_validate_object(..., create=False)for the attribute case, so both methods resolve the attribute identically.The
attribute=Nonepath inget_object_entitiesis unchanged, so directly passingrelative_pathstill works.How to test the behavior
Added
test_get_obj_entities_non_datatype_attribute: adds a ref withattribute='description'and retrieves it with the same attribute. It fails ondev(KeyError: 'description') and passes with this change. The existingtest_get_obj_entities_attribute(DataType-attribute / column case) continues to pass.Checklist
🤖 Generated with Claude Code