Skip to content

feat(actions): add DomainNameResolver for human-friendly domain names #14355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

tulikabhatt
Copy link

Adds DomainNameResolver class to resolve domain URNs to human-readable display names in datahub-actions messages, improving user experience by showing friendly domain names instead of technical identifiers.

Resolves: acryldata/datahub-actions#65

Adds DomainNameResolver class to resolve domain URNs to human-readable display names in datahub-actions messages, improving user experience by showing friendly domain names instead of technical identifiers.

Resolves: acryldata/datahub-actions#65

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions bot added the community-contribution PR or Issue raised by member(s) of DataHub Community label Aug 7, 2025
@datahub-cyborg datahub-cyborg bot added the needs-review Label for PRs that need review from a maintainer. label Aug 7, 2025
@yoonhyejin yoonhyejin requested a review from hsheth2 August 7, 2025 08:32
@yoonhyejin
Copy link
Collaborator

Thanks for raising the PR! @hsheth2 could you take a look at this?

@datahub-cyborg datahub-cyborg bot added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Aug 7, 2025
Copy link
Collaborator

@hsheth2 hsheth2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks reasonable - can we add some tests?

tulikabhatt and others added 2 commits August 7, 2025 21:54
Adds 10 unit test cases covering DomainNameResolver functionality:
- Tests with/without DataHubGraph scenarios
- Validates fallback behavior for missing/empty domain properties
- Verifies NameResolverRegistry integration
- Tests edge cases including None and empty string names
- Ensures proper mocking and API contract verification

All tests pass and follow existing code patterns and conventions.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixes type error where DomainPropertiesClass constructor was passed None for name parameter.
Uses Mock object with name attribute set to None instead to satisfy type checking.

All tests continue to pass and mypy reports success with no issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@datahub-cyborg datahub-cyborg bot added needs-review Label for PRs that need review from a maintainer. and removed pending-submitter-response Issue/request has been reviewed but requires a response from the submitter labels Aug 8, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tests look extremely verbose - I was expecting something more like ~50 lines of code for the tests

@datahub-cyborg datahub-cyborg bot added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Aug 8, 2025
@datahub-cyborg datahub-cyborg bot added needs-review Label for PRs that need review from a maintainer. and removed pending-submitter-response Issue/request has been reviewed but requires a response from the submitter labels Aug 15, 2025
assert entity_name == "Marketing Domain"


def test_domain_name_resolver_with_graph_and_empty_string_name():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is also not necessary imo

Comment on lines 38 to 75
def test_domain_name_resolver_with_graph_no_properties():
"""Test DomainNameResolver when DataHubGraph is available but no properties found"""
resolver = DomainNameResolver()
domain_urn = Urn.from_string("urn:li:domain:marketing-domain")

# Mock DataHubGraph that returns None for domain properties
mock_graph = Mock()
mock_graph.get_aspect.return_value = None

entity_name = resolver.get_entity_name(domain_urn, mock_graph)

# Should call get_aspect with correct parameters
mock_graph.get_aspect.assert_called_once_with(
str(domain_urn), DomainPropertiesClass
)

# Should fallback to the domain ID from the URN
assert entity_name == "marketing-domain"

def test_domain_name_resolver_with_graph_and_properties():
"""Test DomainNameResolver when DataHubGraph returns properties with name"""
resolver = DomainNameResolver()
domain_urn = Urn.from_string("urn:li:domain:marketing-domain")

# Mock DataHubGraph that returns domain properties with a friendly name
mock_graph = Mock()
mock_properties = DomainPropertiesClass(name="Marketing Domain")
mock_graph.get_aspect.return_value = mock_properties

entity_name = resolver.get_entity_name(domain_urn, mock_graph)

# Should call get_aspect with correct parameters
mock_graph.get_aspect.assert_called_once_with(
str(domain_urn), DomainPropertiesClass
)

# Should return the friendly name from properties
assert entity_name == "Marketing Domain"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two tests look extremely similar - can you reduce the code duplication?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, collapsed the two testing scenarios into one.


entity_name = resolver.get_entity_name(domain_urn, mock_graph)

# Should call get_aspect with correct parameters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these comments + docstrings are a bit overzealous. in general, comments should add new information and not just reexplain individual lines of code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, removed the extra comments.

@datahub-cyborg datahub-cyborg bot added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Aug 15, 2025
@datahub-cyborg datahub-cyborg bot added needs-review Label for PRs that need review from a maintainer. and removed pending-submitter-response Issue/request has been reviewed but requires a response from the submitter labels Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution PR or Issue raised by member(s) of DataHub Community needs-review Label for PRs that need review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for domain name resolution to Slack and Teams actions
3 participants