Skip to content

is_effective_base_eol() crashes with UnknownVersionError on build-base: devel #1152

Description

@lengau

Note: This issue was drafted by an AI assistant (GitHub Copilot CLI) on behalf of @lengau, based on investigation of a spread test failure in canonical/imagecraft.

Bug Description

ProjectService.is_effective_base_eol() does not handle a build-base/base of devel (or any base unrecognized by distro-support) the same way its sibling methods do, causing an unhandled UnknownVersionError crash.

Both check_base_is_supported() and base_eol_soon_date() already special-case or defensively catch this:

  • check_base_is_supported() explicitly treats a devel series as always-supported:
    if build_base.series == "devel":
        build_base = None
  • base_eol_soon_date() catches the error and assumes the base is supported:
    except (UnknownDistributionError, UnknownVersionError):
        # If distro-support doesn't know about this base, assume it's supported.
        return None

However, is_effective_base_eol() has neither protection:

def is_effective_base_eol(self) -> bool:
    """Determine whether the base on which to build is end-of-life."""
    base = craft_platforms.DistroBase.from_str(self.get().effective_base)
    return not self._is_supported_on(base=base, date=datetime.date.today())

This method is called from commands/lifecycle.py::_check_supported_base() specifically on the --ignore=unmaintained path:

if "unmaintained" in ignore_items:
    if project_service.is_effective_base_eol():
        ...

So any project with build-base: devel (or base: devel) that runs pack --ignore=unmaintained crashes with:

distro_support.errors.UnknownVersionError: Unknown version ubuntu devel

This is closely related to #986, but that issue was about an outdated pinned distro-support version for a real series (ubuntu@26.04), fixed by bumping the dependency. This case is different: devel is never going to be a version distro-support recognizes, so bumping the dependency won't fix it — the code path itself needs the same devel/UnknownVersionError handling used elsewhere.

To Reproduce

  1. Create a project with:
    base: bare
    build-base: devel
  2. Run <app> pack --ignore=unmaintained.

Relevant log output

imagecraft internal error: UnknownVersionError('Unknown version ubuntu devel')
Traceback (most recent call last):
  ...
  File ".../craft_application/commands/lifecycle.py", line 227, in _check_supported_base
    if project_service.is_effective_base_eol():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../craft_application/services/project.py", line 761, in is_effective_base_eol
    base = craft_platforms.DistroBase.from_str(self.get().effective_base)
  File ".../craft_application/services/project.py", line 694, in _is_supported_on
    support_range = distro_support.get_support_range(base.distribution, base.series)
  File ".../distro_support/__init__.py", line 19, in get_support_range
    raise UnknownVersionError(distribution, version)
distro_support.errors.UnknownVersionError: Unknown version ubuntu devel

Suggested fix

Give is_effective_base_eol() the same treatment as check_base_is_supported()/base_eol_soon_date(): treat a devel series as always-supported (not EOL), and/or catch (UnknownDistributionError, UnknownVersionError) and assume the base is supported when distro-support doesn't recognize it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions