mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-27 09:58:14 +00:00
feat(cli): reject missing urns in datahub get (#11313)
This commit is contained in:
parent
0ce9e946a6
commit
607ad5e1bc
@ -31,6 +31,8 @@ This file documents any backwards-incompatible changes in DataHub and assists pe
|
||||
```
|
||||
Re-running with stateful ingestion should automatically clear up the entities with old URNS and add entities with new URNs, therefore not duplicating the containers or jobs.
|
||||
|
||||
- #11313 - `datahub get` will no longer return a key aspect for entities that don't exist.
|
||||
|
||||
### Potential Downtime
|
||||
|
||||
### Deprecations
|
||||
|
||||
@ -48,16 +48,28 @@ def urn(ctx: Any, urn: Optional[str], aspect: List[str], details: bool) -> None:
|
||||
|
||||
client = get_default_graph()
|
||||
|
||||
if aspect:
|
||||
# If aspects are specified, we need to do the existence check first.
|
||||
if not client.exists(urn):
|
||||
raise click.ClickException(f"urn {urn} not found")
|
||||
|
||||
aspect_data = get_aspects_for_entity(
|
||||
session=client._session,
|
||||
gms_host=client.config.server,
|
||||
entity_urn=urn,
|
||||
aspects=aspect,
|
||||
typed=False,
|
||||
details=details,
|
||||
)
|
||||
|
||||
if not aspect:
|
||||
# If no aspects are specified and we only get a key aspect back, yield an error instead.
|
||||
if len(aspect_data) == 1 and "key" in next(iter(aspect_data)).lower():
|
||||
raise click.ClickException(f"urn {urn} not found")
|
||||
|
||||
click.echo(
|
||||
json.dumps(
|
||||
get_aspects_for_entity(
|
||||
session=client._session,
|
||||
gms_host=client.config.server,
|
||||
entity_urn=urn,
|
||||
aspects=aspect,
|
||||
typed=False,
|
||||
details=details,
|
||||
),
|
||||
aspect_data,
|
||||
sort_keys=True,
|
||||
indent=2,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user