Skip to content

Fix deb sync for missing indices and optimize enabled - #1548

Open
h3krn wants to merge 1 commit into
pulp:mainfrom
h3krn:issue-719-optimize-sync
Open

h3krn wants to merge 1 commit into
pulp:mainfrom
h3krn:issue-719-optimize-sync

Conversation

@h3krn

@h3krn h3krn commented Oct 15, 2026 •

Copy link
Copy Markdown

Why

Optimized syncs (optimize=True, the default) fail with 'NoneType' object has no attribute 'artifact_set_sha256' when the previous repository version lacks a package index that the current sync processes. Every new repository version starts without metadata (AptRepository.initialize_new_version), and _handle_package_index compares with the previous index without a None check. Two cases reach it:

  • An index that is new upstream. A remote asks for an architecture or component that upstream does not serve yet. The sync succeeds and records no index for it. When upstream starts serving it, the next optimized sync crashes.
  • Flat repositories. When the Release file has not changed, _readd_previous_package_indices adds back the previous indices with relative_path__contains=distribution. For flat repos distribution is the literal "flat-repo", which never occurs in an index path such as binary/Packages. So an unchanged sync drops the index, and the next upstream change crashes. This matches the reports in 'NoneType' object has no attribute 'artifact_set_sha256' when syncing a recently updated deb remote #719, including the Jenkins flat repo.

The same filter also breaks distributions whose name is a prefix of another, for example jammy and jammy-updates. If only jammy-updates changes, the unchanged jammy adds back the previous jammy-updates indices too, and the new version fails with Paths are duplicated. It keeps failing on every later sync.

What

  • In _handle_package_index, a missing previous PackageIndex now counts as "changed", so the index is processed instead of compared.
  • In _readd_previous_package_indices, indices are matched by the directory of the Release file instead of by the distribution name. That fixes both the flat repo case and the prefix case.

Benefit

Optimized syncs no longer crash when upstream adds an architecture, component or flat-repo release, and an unchanged sync of a flat repo no longer creates an empty-metadata version. Users no longer need the optimize=False workaround.

Testing

  • New unit test test_sync_optimize.py: fails on main with the AttributeError, passes with the fix.
  • New functional test test_sync_optimize_flat_repo_keeps_package_index: on main the unchanged resync creates version 2, with the fix it stays at version 1.
  • Full pulp_deb suite in oci-env: unit 67 passed, functional 155 passed, 5 skipped (existing skips).
  • Reproduced and verified on pulp_deb 3.10.0 with small apt-ftparchive repos: flat repo, new component, and test / test-updates.

Notes

  • There is no functional test for a new index upstream: no fixture pair has the same distribution with different index sets. A pulp-fixtures addition could cover it.
  • The ReleaseFile comparison in _handle_distribution has the same unguarded pattern, but I found no reachable case. A version from a content modify has no sync info, so optimize turns off. A missing Release fails the sync with DEB0001. So I left it unchanged.

Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

🤖 Generated with Claude Code

closes: #719
Assisted-by: Claude Opus 5.5

When running a sync with optimize=true on a existing deb remote, pulp
compares the new package index with the previous version. When there
is no previous version to compare to, the sync fails. This can happen
when a actual remote only came into existance after a initial sync
already has happened

When a Release file had not changed, the sync added back the previous
indices by matching the distribution name against the index path. For
flat repos the stored name "flat-repo" never matches, so the index was
dropped and the next upstream change hit the error above. A name that
is a prefix of another distribution, such as "jammy" and
"jammy-updates", matched the wrong indices and failed with "Paths are
duplicated". The indices are now matched by the directory of the
Release file.

Closes: pulp#719
Assisted-by: Claude Opus 5.5

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'NoneType' object has no attribute 'artifact_set_sha256' when syncing a recently updated deb remote

1 participant