Repository navigation
fix: skip symlinks in push_path, and keep going after a failed file - #2851
Merged
MattPatchava merged 7 commits intoNov 12, 2026
Merged
Conversation
The push_path docstring says that symbolic links are skipped and that pushing continues past errors, but neither was true. A symlink was pushed by following it, with the link's own 0o777 mode, and a link to a directory or a dangling link raised OSError. That error, like any error for a single file, was caught around the whole source tree, so every remaining file under that source was skipped. Symlinks are now skipped (with a debug log), and errors in push_path and pull_path are collected per file, with the failing file's path in MultiPushPullError.errors, so the rest of the tree is still copied. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…t comment Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Skipping every symlink meant that pushing a named link to a file copied nothing and returned successfully. Skipping is now only for links found while walking a directory. A named link to a directory was already followed, and a named dangling link is now an error, like any other missing source path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The per-link messages are at debug level, which Juju doesn't show by default, so without this nothing says that files are missing from the container. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
These were copied before, so skipping them would silently leave files out of the container for charms where the push works today. Use the target's permissions rather than the link's 0o777, which was the actual bug. Links to directories and dangling links, which raised an error before, are still skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docstring says links are skipped, but Pebble follows them, so a charm reading it would expect a different result to the one it gets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tonyandrewmeyer
marked this pull request as ready for review
November 8, 2026 23:06
benhoyt
reviewed
Nov 9, 2026
benhoyt
left a comment
Collaborator
There was a problem hiding this comment.
Code change looks good, thanks. Just a couple of comments about the tests.
Harness is deprecated, so the new tests get their container from a testing.Context run. Also note why the named-symlink test is distinct from the tree test, as they look like they cover the same case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
benhoyt
approved these changes
Nov 9, 2026
tonyandrewmeyer
added a commit
that referenced
this pull request
Dec 3, 2026
…nch (#2964) This cherry-picks fixes from main that were merged between the last backport round (#2789) and 21 November: * #2738: a non-leader touching its own application databag gets the "is not leader" `RelationDataAccessError` on every access path, rather than a bare `ModelError: permission denied`. * #2780: an `_Abort(0)` from the charm's `__init__` (for example, `load_config(errors='blocked')`) is treated as success in `ops.testing`, as it is in production. * #2787: `Context.trace_data` is no longer empty after the first `Context` with opentelemetry-sdk 1.45. * #2824: ops-tracing sends the correct OTLP span kind for spans that aren't INTERNAL. * #2847 and #2867: a `user-id` or `group-id` of 0 is kept in Pebble services and exec checks. * #2857: the consistency checker accepts tagged Juju versions (like `3.6-beta1`) and action parameters with a list of types. * #2877 and #2876: an error connecting the exec websockets cleans up properly. * #2875: errors reading the Pebble response are wrapped in `ConnectionError`, so `Container.can_connect()` returns `False` rather than raising when Pebble drops the connection. * #2827: OTLP/JSON encoding of bytes and mapping attributes, and of dropped attribute counts. * #2870: exec output is decoded incrementally, so a multi-byte character split across messages no longer raises. * #2872: combining layers in Harness and Scenario keeps the check level, and the original `override`, as Pebble does. * #2871: `pull()` works with paths that have non-ASCII characters or leading or trailing whitespace. * #2855 (partly): `State(opened_ports=[ops.Port(...)])` works, and Scenario ports compare equal to an equal `ops.Port`. * #2917: `get_notices(types=...)` filters correctly in Harness and `ops.testing`. * #2901: `push()` escapes backslashes in the filename. It also includes #2090, which was merged in October 2025 but never backported: an action declared with the shorthand (no params or description, so `null` in `actions.yaml`) no longer crashes the consistency checker. There were some adjustments, which are described in the individual commit messages: * #2780: on this branch, a non-zero `_Abort` is raised as is rather than wrapped in `UncaughtCharmError`, so the new tests expect that. The runtime's `_Abort(0)` handling also covers constructing the charm here, so it now only swallows one once the `Ops` object exists (otherwise a leaked `OPERATOR_DISPATCH` ended in an `AttributeError`). This branch also doesn't have the framework close from #2541 when constructing the charm fails, so `Ops` closes the framework itself after swallowing an `_Abort(0)`. * #2857: `JujuVersion` doesn't accept a bare major version like `'3'`, but the checker on this branch always has (and the tests use them), so I kept accepting those. * #2855: I only ported the `ops.Port` and equality parts. The duplicate-entity checks could start failing existing tests, which seems wrong for a maintenance release. The other `State` fixes in #2855 (comparing unit IDs with `is not`, the shared default `BindAddress`, the `deferred()` error message, and the `get_relation` docstring) aren't included either. `State` only replaced `opened_ports` when the converted list compared unequal, which the new equality defeats, so it now always stores the converted ports. * #2875: before Python 3.10, `socket.timeout` isn't a subclass of `TimeoutError`, so it's checked for as well. Otherwise a timeout waiting for Pebble's response became a plain `ConnectionError` on 3.8 and 3.9, and `wait_change()` stopped retrying it. * #2901: I left out the new `ValueError` for a path containing CR, LF, or NUL. It isn't an `OSError` or a `pebble.Error`, so `Container.push_path()` would stop collecting it and give up on the remaining files. Those paths still get Pebble's `APIError`, as before. `push()` only takes a `str` here, so the real Pebble tests (this one and the #2871 one) pass `str(path)`. * There's an extra commit that skips three of the #2827 tests when opentelemetry-sdk drops bytes, mapping, and mixed-type list values before the encoder sees them. The root lock on this branch has 1.34, which does, so `tox -e coverage-tracing` failed. They still run under `tracing/`. #2738 can turn a charm's passing unit tests red, because Harness and Scenario now raise for something production already did, so the 2.23.x release notes should call it out. Something like: > In Harness and `ops.testing`, a non-leader unit can no longer read its own application databag with `in`, `len()` or iteration, or `update()` it, matching what happens in production ([#2738](#2738)). Unit tests that did this will now raise `RelationDataAccessError`. I left out #2748 (it's built on the hookcmds-based error handling, so would need rewriting), #2851 (`push_path` skipping symlinks is a behaviour change), and #2878 (`CheckInfo.level` changes from `None` to `UNSET`). Fixes merged after 21 November can go in the next round. I've run `tox -e lint`, `static`, `unit`, `py3.8-unit`, `coverage-tracing`, and `pebble` locally, as well as lint, static, and unit in `tracing/`. --------- Co-authored-by: James Garner <james.garner@canonical.com> Co-authored-by: Gangavarapu Vivek <gangavarapu.0104@gmail.com> Co-authored-by: Suyash Bhattarai <133975972+ItsM0rty@users.noreply.github.com> Co-authored-by: Ben Hoyt <ben.hoyt@canonical.com> Co-authored-by: nancy <singhnancy2004@gmail.com> Co-authored-by: Matt Patchava <matt.patchava@canonical.com> Co-authored-by: Indian-boult <64060864+Indian-boult@users.noreply.github.com> Co-authored-by: Dima Tisnek <dima.tisnek@canonical.com>
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.
The
push_pathdocstring says that symbolic links are skipped and that pushing continues past errors, but neither was true. A symlink was pushed by following it (with the link's own0o777mode, since theFileInfocomes fromlstat), and a link to a directory or a dangling link raisedOSError. That error, like any error for a single file, was caught around the whole source tree, so every remaining file under that source was skipped.Symlinks are now skipped (with a debug log), and errors in
push_pathandpull_pathare collected per file, with the failing file's path inMultiPushPullError.errors, so the rest of the tree is still copied.This is a behaviour change for anyone relying on symlinks being followed, but the docstring has always said they're skipped, so I think fixing the code is the right way around. I've left
pull_pathfollowing symlinks (Pebble does the reading there), which is a little inconsistent.