Skip to content

SEC-9872 - #83

Merged
yasserfaraazkhan merged 1 commit into
masterfrom
SEC-9872
Mar 17, 2026
Merged

SEC-9872#83
yasserfaraazkhan merged 1 commit into
masterfrom
SEC-9872

Conversation

@yasserfaraazkhan

@yasserfaraazkhan yasserfaraazkhan commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

This pull request refactors the logic for generating names for E2E and CMT test instances to improve consistency, maintainability, and DNS safety. Helper functions are introduced to centralize and standardize name creation, replacing repeated string manipulation code throughout the codebase.

NONE

Summary by CodeRabbit

  • Refactor
    • Unified instance naming approach across internal systems for improved consistency and DNS compliance.
    • Simplified naming logic by centralizing name generation helpers, removing redundant per-platform naming variations.

@mm-cloud-bot mm-cloud-bot added the release-note-none Denotes a PR that doesn't merit a release note. label Mar 13, 2026
@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes introduce three new DNS-safe naming helper functions in e2e_tests.go and replace existing ad-hoc naming logic in push_events.go and workflow_run.go with unified calls to these helpers, removing redundant sanitization and length-truncation logic across E2E test instance creation.

Changes

Cohort / File(s) Summary
DNS-Safe Naming Helper Functions
server/e2e_tests.go
Introduces e2eUniqueSuffix() to generate an 8-character hex suffix, sanitizeForDNS(s) to lowercase and replace special characters, and e2eInstanceName() to construct DNS-safe, length-limited instance names respecting a 62-character cap minus DNS suffix length.
Naming Logic Consolidation
server/push_events.go, server/workflow_run.go
Replaces per-file ad-hoc naming, sanitization, and truncation logic with unified e2eInstanceName() calls. Removes manual repoPrefix/branch concatenation, version sanitization, and prior max-length calculations. Streamlines instance name construction while maintaining existing instance creation and error handling flows.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The pull request title 'SEC-9872' is a ticket reference only and does not describe the actual changes made to the codebase. Change the title to something descriptive like 'Refactor E2E and CMT instance naming with centralized helpers' or 'Unify instance name generation with DNS-safe naming helpers'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch SEC-9872
📝 Coding Plan
  • Generate coding plan for human review comments

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
server/e2e_tests.go (1)

41-48: Consider handling additional invalid DNS characters.

The current implementation only replaces _, ., / but DNS labels may only contain a-z, 0-9, and - (not at start/end). Characters like spaces, @, #, or other special characters would pass through unchanged.

If inputs are guaranteed to be well-formed version strings, this is likely fine. Otherwise, consider a more robust approach.

♻️ Suggested more robust sanitization
 func sanitizeForDNS(s string) string {
 	s = strings.ToLower(s)
-	s = strings.ReplaceAll(s, "_", "-")
-	s = strings.ReplaceAll(s, ".", "-")
-	s = strings.ReplaceAll(s, "/", "-")
+	var result strings.Builder
+	for _, r := range s {
+		if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') {
+			result.WriteRune(r)
+		} else {
+			result.WriteRune('-')
+		}
+	}
+	// Collapse consecutive hyphens and trim leading/trailing hyphens
+	s = result.String()
+	for strings.Contains(s, "--") {
+		s = strings.ReplaceAll(s, "--", "-")
+	}
+	s = strings.Trim(s, "-")
 	return s
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/e2e_tests.go` around lines 41 - 48, sanitizeForDNS currently only
replaces "_", ".", "/" and may leave other invalid characters (spaces,
punctuation, etc.) in the output; update sanitizeForDNS to be robust: lowercase
input, replace any character not in [a-z0-9-] with '-', collapse consecutive '-'
into a single '-', and trim leading/trailing '-' so the result is a valid DNS
label; use a regexp or rune loop inside sanitizeForDNS to implement these steps
and keep the function signature the same.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@server/e2e_tests.go`:
- Around line 41-48: sanitizeForDNS currently only replaces "_", ".", "/" and
may leave other invalid characters (spaces, punctuation, etc.) in the output;
update sanitizeForDNS to be robust: lowercase input, replace any character not
in [a-z0-9-] with '-', collapse consecutive '-' into a single '-', and trim
leading/trailing '-' so the result is a valid DNS label; use a regexp or rune
loop inside sanitizeForDNS to implement these steps and keep the function
signature the same.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d1627e43-68c2-4afa-a486-6a0cd7d9ade6

📥 Commits

Reviewing files that changed from the base of the PR and between dc0af5e and 5ffc0e8.

📒 Files selected for processing (3)
  • server/e2e_tests.go
  • server/push_events.go
  • server/workflow_run.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note-none Denotes a PR that doesn't merit a release note.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants