Skip to content

Bug: Workspace name isnt properly validated for custom images #1691

Open
@KronsyC

Description

@KronsyC

Checklist

Describe your issue

When using custom dockerfiles, the image generated takes part of its name from the cargo workspace

1:56:39  + cross build --profile yocto --target aarch64-unknown-linux-gnu

21:56:40  info: syncing channel updates for '1.85.1-x86_64-unknown-linux-gnu'

21:56:40  

21:56:40    1.85.1-x86_64-unknown-linux-gnu unchanged - rustc 1.85.1 (4eb161250 2025-03-15)

21:56:40  

21:56:40  ERROR: failed to build: invalid tag "cross-custom-_scm_instant-firmware_pr--head:aarch64-unknown-linux-gnu-fdc31": invalid reference format

21:56:40  Error: 

21:56:40     0: 
could not run container

21:56:40     1: 
when building custom image

21:56:40     2: 
when building dockerfile

21:56:40     3: 
`docker build --label 'org.cross-rs.for-cross-target=aarch64-unknown-linux-gnu' --label 'org.cross-rs.workspace_root=/home/jenkins-agent/jenkins/workspace/_SCM_Instant-Firmware_PR-68-head' --tag cross-custom-_scm_instant-firmware_pr--head:aarch64-unknown-linux-gnu-fdc31 --build-arg 'CROSS_DEB_ARCH=arm64' --build-arg 'CROSS_BASE_IMAGE=ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5' --file ./controller/Dockerfile /home/jenkins-agent/jenkins/workspace/_SCM_Instant-Firmware_PR-68-head` failed with exit status: 1

21:56:40  

This validation code just fails to account for the weird case of an adjacent - and _

if your workspace starts with _, this happens

Came across this due to Jenkins' weird auto-generated workspace names

What target(s) are you cross-compiling for?

No response

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5

Example

No response

Additional information / notes

No response

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