Repository navigation
fix: preserve extra_fields in Link.clone - #1860
Merged
jsignell merged 2 commits intoNov 19, 2026
Merged
Conversation
Link.clone() rebuilt the link from rel, target, media_type and title only, so extra_fields were dropped from every link of a Catalog.clone() or Catalog.full_copy(). Deep-copy them into the clone so that the copy keeps the fields without sharing mutable state with the original.
gadomski
self-requested a review
November 19, 2026 11:59
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 19, 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.
Related Issue(s):
Links are not correctly copied byCatalog.full_copy()#1856Description:
Summary
Link.clone()dropsextra_fields, so everyclone()/full_copy()of anItem,CollectionorCatalog(andItemCollection.clone()) loses additional link fields.Root cause
Link.clone()rebuilt the link fromrel,target,media_typeandtitleonly, without passingextra_fieldsto the constructor. BothCatalog.clone()andSTACObject.full_copy()copy links throughLink.clone(), so any additional link fields (e.g.foo:bar) were lost.Fix
Pass
extra_fields=deepcopy(self.extra_fields)inLink.clone(). The deep copy keeps the clone independent from the original, the same approach asAsset.clone()and consistent with howCatalog.clone()already handles the catalog's ownextra_fields.Verification
Locally on Python 3.12. New tests (they fail on
main, pass with the fix):tests/test_link.py:test_clone_preserves_extra_fields,test_clone_does_not_share_extra_fieldstests/test_catalog.py:test_clone_link_extra_fields,test_full_copy_link_extra_fieldsCommands and results:
pytest tests/test_link.py tests/test_catalog.py -k "clone_preserves or clone_does_not or clone_link_extra or full_copy_link_extra": 4 failed before the fix, 4 passed afterpytest: 1562 passed, 18 skippedruff check,ruff format --check,codespellandmypy --no-incrementalon the changed files: cleanPR Checklist:
pre-commit run --all-files) — ruff, ruff-format, codespell and mypy were run directly on the changed files; pyupgrade and doc8 were not run (no.rstchanges)pytest)This PR was prepared with AI assistance (Claude Code). I have reviewed the change and the test results.