Fix misleading error message in cert generation when domains exist but cert generation fails #1494
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes the misleading error message in
defang cert genthat would display "Nodomainnamefound in compose file; no HTTPS cert generation needed" even when domain names were present in the compose file but certificate generation failed for other reasons.Problem
The original logic only checked if any certificates were processed (
cnt == 0) to determine whether to show the "no domainname found" message. However, the countercntis only incremented for services that require ACME certificate generation (whereserviceInfo.ZoneId == ""). This caused the misleading message to appear in scenarios where:Solution
Added a
hasDomainscheck that scans the compose project to determine if any domain names actually exist before showing the message. The message is now only displayed when both conditions are true:cnt == 0(no certificate generation was processed)!hasDomains(no domain names exist in the compose file)This ensures users only see the "no domainname found" message when it's actually accurate, while real certificate generation errors are properly surfaced without confusion.
Changes
GenerateLetsEncryptCert()insrc/pkg/cli/cert.goto add domain detection logicTestHasDomains()test to validate the domain detection functionalityTesting
All existing tests pass, and the new test validates that the domain detection logic correctly identifies when domains are present in compose files across various scenarios.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
ask.defang.iogo test -short ./...(dns block)/tmp/go-build2519147953/b1331/tests.test -test.testlogfile=/tmp/go-build2519147953/b1331/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.short=true(dns block)blah.example.com/tmp/go-build2519147953/b1255/cli.test -test.testlogfile=/tmp/go-build2519147953/b1255/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.short=true(dns block)/tmp/go-build56874474/b001/cli.test -test.testlogfile=/tmp/go-build56874474/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.run=Test.* -test.v=true(dns block)fabric-prod1.defang.dev/tmp/go-build2519147953/b1207/command.test -test.testlogfile=/tmp/go-build2519147953/b1207/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.short=true(dns block)www.googleapis.com/tmp/go-build2519147953/b1290/gcp.test -test.testlogfile=/tmp/go-build2519147953/b1290/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.short=true(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.