Skip to content

Cannot set separate url and local_path when assigning to variant.paths #227

@lubomir

Description

@lubomir

Caution

AI generated report follows

Summary

When assigning paths to variant.paths.repository[arch], variant.paths.debug_repository[arch], or variant.paths.source_repository[arch], there is no way to set different values for url and local_path in the resulting Location object.

Environment

  • productmd version: Development branch commit b719ac380fa94a3c68093479957d3ae1aab75c6b
  • Python version: 3.14.3

Current Behavior

When assigning to variant paths, the behavior varies depending on the type assigned:

  1. Assigning a string: Both url and local_path are set to the same string value

    variant.paths.repository["x86_64"] = "https://example.com/repo"
    # Results in: url="https://example.com/repo", local_path="https://example.com/repo"
  2. Assigning a dict: Causes TypeError during serialization

    variant.paths.repository["x86_64"] = {
        "url": "https://example.com/repo",
        "local_path": "compose/repo"
    }
    # Results in: TypeError during ci.dump() - productmd tries to assign the dict to local_path
  3. Assigning a Location object: Causes TypeError during serialization

    from productmd.common import Location
    loc = Location()
    loc.url = "https://example.com/repo"
    loc.local_path = "compose/repo"
    variant.paths.repository["x86_64"] = loc
    # Results in: TypeError - productmd wraps it in another Location, setting local_path to the Location object

Expected Behavior

Users should be able to assign a Location object directly without re-wrapping it in another Location

Example of desired usage:

from productmd.composeinfo import ComposeInfo, Variant

ci = ComposeInfo()
# ... set up compose metadata ...

variant = Variant(ci)
variant.id = "BaseOS"
variant.uid = "BaseOS"
variant.name = "BaseOS"
variant.type = "variant"
variant.arches = {"x86_64"}
ci.variants.add(variant)

from productmd.common import Location
loc = Location()
loc.url = "https://pulp.example.com/pulp/content/RHEL-10-10.0-20260311.0/BaseOS-x86_64"
loc.local_path = "BaseOS/x86_64/os"
variant.paths.repository["x86_64"] = loc

ci.dump("composeinfo.json")

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