← Back to issue list

init: normalize long directory-derived snap names

View original Github issue

Metadata

Project
snapcraft
Number
#6103
Type
pull request
State
closed
Author
gcomneno
Labels
—
Created
Updated
Closed

Current evaluation

Closed unmerged and superseded by PR #6216 (commit 254546337), which fixed init for long directory-derived names while retaining strict explicit-name validation.

Resolution: closed superseded

Reason: PR #6103 was closed without merge while maintainers requested further triage. PR #6216 later replaced its approach and was merged as commit 254546337, closing issue #6093.

Evaluated by: mr-cal-bot

No scores available.

Issue body

## Summary Fix `snapcraft init` when the current directory name is longer than the snap name limit. When the project name is derived automatically from the directory, Snapcraft now: - truncates it to the maximum snap name length - removes a trailing hyphen after truncation - validates the normalized name before project initialization Explicit names passed with `--name` keep the existing strict validation behaviour. Closes #6093. ## Why Today, `snapcraft init` fails if the current working directory name is longer than 40 characters, even though other Craft tools initialize successfully in equivalent cases. This change keeps the special handling limited to directory-derived names and avoids changing the contract for explicit `--name` values. ## Implementation - add `MAX_SNAP_NAME_LENGTH` - add `_normalize_snap_name()` for directory-derived names - add `_validate_snap_name()` to centralize snap-specific validation, including the 40-character limit - override `validate_project_name(..., use_default=True)` so only directory-derived names are normalized - keep `initialise_project()` strict for explicit project names - preserve exception chaining for the reserved `snap/` directory path error ## Tests Added or updated tests to cover: - explicit invalid names still failing in the init service - normalization helper behaviour: - truncation - trailing hyphen removal - `snapcraft init` succeeding when the current directory name is too long - `snapcraft init --name <long-name>` still failing and not creating `snap/snapcraft.yaml` Also updated the fake provider test double to implement `list_instances()` with the current provider interface so the unit tests remain compatible.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed superseded Closed unmerged and superseded by PR #6216 (commit 254546337), which fixed init for long directory-derived names while retaining strict explicit-name validation.
stealth/space-bunny-alpha — closed superseded PR #6103 was closed unmerged after issue-level triage was requested. The underlying problem was later fixed by merged PR #6216 in commit 254546337.
stealth/space-bunny-alpha — closed superseded PR #6103 was closed unmerged as untriaged; its normalization approach was superseded by merged PR #6216 (commit 254546337), which fixed #6093.
stealth/space-bunny-alpha — closed superseded PR #6103 (normalize long directory-derived snap names) was closed unmerged by maintainer @bepri, who said it could not be accepted before the team triaged #6093. The fix landed instead via merged PR #6216 (commit 2545463).
stealth/space-bunny-alpha — closed superseded Normalization PR was not merged; #6216 replaced it, allowing init with directory-derived names longer than 40 characters in commit 254546337.
qwen/qwen3.6-35b-a3b — — PR normalizing long directory-derived snap names for snapcraft init was closed without merging. Maintainers declined the changes, citing untriaged status and lack of readiness to implement the fix.
qwen3.6-35b-a3b-mtp-q6 — — Normalization of long directory-derived snap names for snapcraft init was declined. Maintainers stated the related issue has not been triaged and the team is not ready to accept the change, requesting contributors discuss solutions in the issue first.

Update history

No update history recorded yet.

Related work

Related issues

Issue Project State Summary Similarity
#6216 fix(init): allow long directory names snapcraft merged Merged #6216 (commit 254546337), fixing snapcraft init to use a valid default for invalid directory-derived names while preserving validation of explicit names; closes #6093.
81%