Skip to content
Open
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions charmcraft/application/commands/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,11 +1534,15 @@ def run(self, parsed_args: argparse.Namespace) -> None:
for lib in local_libs_data
]
)
except errors.LibraryError:
raise errors.LibraryError(
message=f"Library {parsed_args.library} not found in Charmhub.",
logpath_report=False,
)
except errors.LibraryError as e:
# If a specific library was requested, use that in the error message
# Otherwise, re-raise the original error which should have details
if parsed_args.library:
raise errors.LibraryError(
message=f"Library {parsed_args.library} not found in Charmhub.",
logpath_report=False,
) from e
raise

# check if something needs to be done
analysis = []
Expand All @@ -1559,7 +1563,7 @@ def run(self, parsed_args: argparse.Namespace) -> None:
break
else:
raise errors.LibraryError(
message=f"Library {parsed_args.library} not found in Charmhub.",
message=f"Library {lib_data.full_name} not found in Charmhub.",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot write tests for this behaviour. Including a spread test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests in commit 026f5c1:

Integration test (test_fetchlib_all_library_not_found):

  • Creates a library with a fake lib_id that doesn't exist in Charmhub
  • Runs fetch-lib without arguments
  • Verifies error message shows charms.nonexistent_charm.v0.nonexistent_lib instead of None

Spread test (store/libraries-not-found):

  • Creates a charm directory with a library using a fake lib_id
  • Runs charmcraft fetch-lib without arguments
  • Verifies error message contains the library name and not "Library None"
  • Tests the actual command-line behavior end-to-end

logpath_report=False,
)
emit.debug(f"Store tip: {tip}")
Expand Down
Loading