Skip to content

Fix panic in CD List#1962

Merged
lionello merged 4 commits intomainfrom
revert-1961-revert-1960-lio/fix-cd-list
Mar 6, 2026
Merged

Fix panic in CD List#1962
lionello merged 4 commits intomainfrom
revert-1961-revert-1960-lio/fix-cd-list

Conversation

@lionello
Copy link
Copy Markdown
Member

@lionello lionello commented Mar 5, 2026

Reverts #1961, reapplying #1960

The previous PR fixed the panic but regressed by only ever showing CD logs, because the QueryLogs code can't tell whether the caller wants all logs or only CD/task logs. To fix this, I added a separate LogType for CD.

Summary by CodeRabbit

  • New Features

    • Added a CD log type and enabled CD log aggregation/tailing in previews and related CLI flows.
  • Bug Fixes

    • Better handling of CD/task-based log tailing and etag-derived task IDs.
    • Skip fetching playground upload URLs for list commands.
    • Clearer DNS error message advising VPN checks.
  • Tests

    • Added tests for CD log type and task ID derivation.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

Introduces a new LogTypeCD and updates log-tailing to treat CD logs separately across the CLI and BYOC clients; AWS BYOC log querying now derives task IDs for CD etags and tails logs by task ID; minor GCP and test adjustments and a user-facing error message change in DNS delegation set creation.

Changes

Cohort / File(s) Summary
Log Type Constants
src/pkg/logs/log_type.go, src/pkg/logs/log_type_test.go
Adds LogTypeCD, updates LogTypeAll to math.MaxUint32, includes LogTypeCD in maps/slices, and adds a test for the CD string.
CLI Command Log Tailing
src/cmd/cli/command/compose.go, src/pkg/cli/cd.go, src/pkg/cli/estimate.go, src/pkg/cli/preview.go
Switches tailing defaults to include or prefer LogTypeCD (compose default, cd/list behavior, estimate preview, preview combines build+CD); also skips fetching Playground upload URLs for the List command.
AWS BYOC Log Querying
src/pkg/cli/client/byoc/aws/byoc.go
Refactors CD log path: adds deriveTaskID, replaces queryOrTailCdLogs with queryOrTailLogsByTaskID, adjusts getLogGroupInputs to tail CD logs by type, and updates follow vs range logic to support task-ID-based tailing.
AWS BYOC Tests
src/pkg/cli/client/byoc/aws/byoc_test.go
Updates tests to use ptr.String, switches test calls to queryOrTailLogsByTaskID, and adds TestDeriveTaskID covering etag/CD ARN scenarios.
AWS BYOC Utilities
src/pkg/cli/client/byoc/aws/domain.go
Rewords final error in createUsableDelegationSet to user-facing guidance about possible VPN DNS interception.
GCP BYOC Log Handling
src/pkg/cli/client/byoc/gcp/byoc.go
Includes LogTypeCD alongside LogTypeBuild when selecting CloudBuild logs.
Tests / Minor
src/pkg/cli/getServices_test.go
Changes invalid endpoint test to use https://invalid-endpoint (protocol only).

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant BYOC_AWS
  participant ECS_CloudWatch

  CLI->>BYOC_AWS: QueryLogs(request with etag, logType)
  BYOC_AWS->>BYOC_AWS: deriveTaskID(etag, cdTaskArn)
  alt etag refers to CD task
    BYOC_AWS->>ECS_CloudWatch: Tail logs by taskID (follow/range)
    ECS_CloudWatch-->>BYOC_AWS: Stream log events
    BYOC_AWS-->>CLI: Forward aggregated log events
  else legacy or non-CD
    BYOC_AWS->>ECS_CloudWatch: Query logs by etag/stream filters
    ECS_CloudWatch-->>BYOC_AWS: Return matched logs
    BYOC_AWS-->>CLI: Return results
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jordanstephens
  • edwardrf

Poem

🐰 A new CD flag hops into sight,
Task IDs guide the tail each night,
From build to preview, logs align,
Rabbits cheer the clearer line,
Hooray — logs now hop in light! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Fix panic in CD List' directly relates to the main objective of the PR, which is to fix a panic issue in the CD List functionality by reapplying changes from PR #1960.
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 (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 revert-1961-revert-1960-lio/fix-cd-list

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

@lionello lionello requested a review from edwardrf March 5, 2026 23:57
@lionello lionello marked this pull request as ready for review March 5, 2026 23:57
@lionello lionello requested a review from jordanstephens as a code owner March 5, 2026 23:57
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/pkg/logs/log_type.go (1)

26-30: ⚠️ Potential issue | 🟡 Minor

Include LogTypeCD in AllLogTypes.

String() and CLI help text depend on AllLogTypes. Without LogTypeCD there, combined values like LogTypeBuild | LogTypeCD stringify incompletely and --type help omits CD.

🔧 Proposed fix
 var AllLogTypes = []LogType{
 	LogTypeRun,
 	LogTypeBuild,
+	LogTypeCD,
 	LogTypeAll,
 }

Also applies to: 82-99

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pkg/logs/log_type.go` around lines 26 - 30, AllLogTypes currently omits
LogTypeCD causing String() and CLI help to miss CD; add LogTypeCD to the
AllLogTypes slice (alongside LogTypeRun, LogTypeBuild, LogTypeAll) and update
the other AllLogTypes-like collection referenced later in the file (the
alternate slice around the LogType definitions used for String()/help
generation) so combined values like LogTypeBuild | LogTypeCD stringify and
appear in --type help correctly.
🧹 Nitpick comments (2)
src/pkg/cli/getServices_test.go (1)

390-392: Use a reserved invalid TLD for deterministic network-failure tests.

invalid-endpoint can resolve on some networks via search domains. invalid.invalid is guaranteed invalid.

🔧 Suggested tweak
-			endpoint:        "https://invalid-endpoint",
+			endpoint:        "https://invalid.invalid",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pkg/cli/getServices_test.go` around lines 390 - 392, Replace the
non-deterministic test endpoint used in the "Invalid endpoint" test case: update
the endpoint value referenced by the test case (the endpoint field in the
failing case named "Invalid endpoint" in getServices_test) from
"https://invalid-endpoint" to a reserved invalid TLD such as
"https://invalid.invalid" so DNS resolution cannot succeed on some networks and
the network-failure test is deterministic.
src/pkg/logs/log_type_test.go (1)

33-45: Add a combined CD case to lock composite String() behavior.

Single-value coverage is good; adding a combo case prevents regressions in bitfield formatting.

✅ Suggested test addition
 	{
 		{"unspecified", LogTypeUnspecified, "UNSPECIFIED"},
 		{"cd", LogTypeCD, "CD"},
 		{"run", LogTypeRun, "RUN"},
 		{"build", LogTypeBuild, "BUILD"},
+		{"build and cd", LogTypeBuild | LogTypeCD, "BUILD,CD"},
 		{"run and build", LogTypeRun | LogTypeBuild, "RUN,BUILD"},
 		{"all", LogTypeAll, "ALL"},
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pkg/logs/log_type_test.go` around lines 33 - 45, The test suite
TestLogTypeString lacks a composite case that includes the CD bit, so add a
combined-case entry to the tests slice to verify bitfield formatting for
composites (e.g., add an entry like {"cd+run", LogTypeCD | LogTypeRun,
"CD,RUN"}) to ensure LogType.String() correctly joins multiple flags; update the
tests slice in TestLogTypeString to include this new test case alongside the
existing ones.
🤖 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/estimate.go`:
- Around line 72-75: GeneratePreview currently tails only CD logs (TailOptions
with LogType set to logs.LogTypeCD), which misses preview output classified as
build logs; update GeneratePreview to tail both Build and CD logs — either by
changing TailOptions.LogType to include both (e.g., logs.LogTypeAll or a
combined value) or by invoking the tailing call twice with TailOptions using
logs.LogTypeBuild and logs.LogTypeCD (matching the approach in preview.go) so
all preview-related messages are captured; modify the code that constructs
TailOptions and/or the tail invocation inside GeneratePreview to ensure both log
types are processed.

In `@src/pkg/logs/log_type.go`:
- Around line 18-23: The LogType constants have wrong numeric values and
All/AllLogTypes omits LogTypeCD; update the LogType declarations so their
numeric values match the protobuf (explicitly assign LogTypeCD=1,
LogTypeBuild=2, LogTypeRun=4) and restore LogTypeUnspecified=0, then define
LogTypeAll (or AllLogTypes) as the bitwise OR of LogTypeCD, LogTypeBuild and
LogTypeRun so LogTypeCD is included in all-string/iteration logic; touch the
constants block that declares LogTypeUnspecified, LogTypeCD, LogTypeRun,
LogTypeBuild and the LogTypeAll/AllLogTypes definition to apply these changes.

---

Outside diff comments:
In `@src/pkg/logs/log_type.go`:
- Around line 26-30: AllLogTypes currently omits LogTypeCD causing String() and
CLI help to miss CD; add LogTypeCD to the AllLogTypes slice (alongside
LogTypeRun, LogTypeBuild, LogTypeAll) and update the other AllLogTypes-like
collection referenced later in the file (the alternate slice around the LogType
definitions used for String()/help generation) so combined values like
LogTypeBuild | LogTypeCD stringify and appear in --type help correctly.

---

Nitpick comments:
In `@src/pkg/cli/getServices_test.go`:
- Around line 390-392: Replace the non-deterministic test endpoint used in the
"Invalid endpoint" test case: update the endpoint value referenced by the test
case (the endpoint field in the failing case named "Invalid endpoint" in
getServices_test) from "https://invalid-endpoint" to a reserved invalid TLD such
as "https://invalid.invalid" so DNS resolution cannot succeed on some networks
and the network-failure test is deterministic.

In `@src/pkg/logs/log_type_test.go`:
- Around line 33-45: The test suite TestLogTypeString lacks a composite case
that includes the CD bit, so add a combined-case entry to the tests slice to
verify bitfield formatting for composites (e.g., add an entry like {"cd+run",
LogTypeCD | LogTypeRun, "CD,RUN"}) to ensure LogType.String() correctly joins
multiple flags; update the tests slice in TestLogTypeString to include this new
test case alongside the existing ones.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1825afd0-a3b1-467a-a5b0-d2251c6b1cb9

📥 Commits

Reviewing files that changed from the base of the PR and between 91ac0c0 and 0cb12b9.

📒 Files selected for processing (11)
  • src/cmd/cli/command/compose.go
  • src/pkg/cli/cd.go
  • src/pkg/cli/client/byoc/aws/byoc.go
  • src/pkg/cli/client/byoc/aws/byoc_test.go
  • src/pkg/cli/client/byoc/aws/domain.go
  • src/pkg/cli/client/byoc/gcp/byoc.go
  • src/pkg/cli/estimate.go
  • src/pkg/cli/getServices_test.go
  • src/pkg/cli/preview.go
  • src/pkg/logs/log_type.go
  • src/pkg/logs/log_type_test.go

Comment thread src/pkg/cli/estimate.go
Comment thread src/pkg/logs/log_type.go Outdated
Copy link
Copy Markdown
Contributor

@edwardrf edwardrf left a comment

Choose a reason for hiding this comment

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

Verified to have fixed the bug on aws and works on gcp

@lionello lionello merged commit 70f85a4 into main Mar 6, 2026
14 checks passed
@lionello lionello deleted the revert-1961-revert-1960-lio/fix-cd-list branch March 6, 2026 13:28
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