Skip to content

Commit 7c15649

Browse files
committed
Raise exception if add_if_missing is true for ownerless asset
1 parent 3aac28a commit 7c15649

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pystac/extensions/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ def validate_has_extension(
138138
add_if_missing : Whether to add the schema URI to the object if the URI is
139139
not already present.
140140
141+
Raises:
142+
STACError : If ``add_if_missing`` is ``True`` and ``extensible`` is None.
141143
"""
142144
if add_if_missing:
145+
if extensible is None:
146+
raise pystac.STACError(
147+
"Can only add schema URIs to Assets with an owner."
148+
)
143149
cls.add_to(extensible)
144150

145151
if extensible is None:

0 commit comments

Comments
 (0)