Skip to content

fix: warn when project or service name exceeds 16 characters - #2080

Merged
lionello merged 1 commit into
mainfrom
jordan/warn-project-service-name-length
Apr 29, 2026
Merged

fix: warn when project or service name exceeds 16 characters#2080
lionello merged 1 commit into
mainfrom
jordan/warn-project-service-name-length

Conversation

@jordanstephens

@jordanstephens jordanstephens commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Description

Linked Issues

Checklist

  • I have performed a self-review of my code
  • I have added appropriate tests
  • I have updated the Defang CLI docs and/or README to reflect my changes, if necessary

Summary by CodeRabbit

  • New Features

    • Added warnings when project and service names exceed 16 characters to alert users of potential resource naming issues.
  • Tests

    • Updated test fixtures to reflect new name-length validation warnings across multiple compose configurations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds validation warnings to detect when Docker Compose project and service names exceed 16 characters. The core implementation adds warning emissions in the FixupServices function, with corresponding updates to test fixtures to reflect the newly detected warnings.

Changes

Cohort / File(s) Summary
Core Implementation
src/pkg/cli/compose/fixup.go
Added term.Warnf warnings in FixupServices to flag project and service names exceeding 16 characters as potential issues for downstream resource naming.
Test Fixtures
src/testdata/*/compose.yaml.warnings
Updated warning output files across 12 test suites to include newly detected name-length warnings for project and service names exceeding 16 characters.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Possibly related PRs

Suggested reviewers

  • lionello

Poem

🐰 Long names in compose, oh what a fright!
Sixteen characters, not quite right—
We warn and we check with a thump of our feet,
Resource names truncated? Never so neat! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding warnings for project/service names exceeding 16 characters, which is confirmed by the modifications across the fixup function and all testdata warning files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jordan/warn-project-service-name-length

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/pkg/cli/compose/fixup.go`:
- Around line 46-48: The length checks on project.Name and svccfg.Name use
len(...) which counts bytes and will misreport non-ASCII names; replace those
checks with utf8.RuneCountInString(project.Name) and
utf8.RuneCountInString(svccfg.Name) (import "unicode/utf8") so the comparisons
use rune/character counts, or if the real constraint is byte-length, change the
warning text to say "bytes" instead of "characters"; update the two places that
currently compare len(project.Name) > 16 and len(svccfg.Name) > 16 accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3f616338-8248-4fc8-a495-be3596aba516

📥 Commits

Reviewing files that changed from the base of the PR and between 16a39d5 and cefec22.

📒 Files selected for processing (13)
  • src/pkg/cli/compose/fixup.go
  • src/testdata/ambiguous-strings/compose.yaml.warnings
  • src/testdata/compose-go-warn/compose.yaml.warnings
  • src/testdata/dockerfile-validation-errors/compose.yaml.warnings
  • src/testdata/fixupenv/compose.yaml.warnings
  • src/testdata/llm/compose.yaml.warnings
  • src/testdata/longname/compose.yaml.warnings
  • src/testdata/mongo/compose.yaml.warnings
  • src/testdata/networks/compose.yaml.warnings
  • src/testdata/ports/compose.yaml.warnings
  • src/testdata/postgres/compose.yaml.warnings
  • src/testdata/railpack/compose.yaml.warnings
  • src/testdata/redis/compose.yaml.warnings

Comment thread src/pkg/cli/compose/fixup.go
@lionello
lionello merged commit 2391057 into main Apr 29, 2026
14 checks passed
@lionello
lionello deleted the jordan/warn-project-service-name-length branch April 29, 2026 19:40
lionello added a commit that referenced this pull request Apr 30, 2026
…ame issues

per #2080

Co-authored-by: Copilot <copilot@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants