Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 3, 2025

Description

Fixes the misleading error message in defang cert gen that would display "No domainname found 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. Additionally, provides informative feedback when the deployment is not yet complete.

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 counter cnt is only incremented for services that require ACME certificate generation (where serviceInfo.ZoneId == ""). This caused the misleading message to appear in scenarios where:

  1. Domain names exist but are managed by cloud providers (have a ZoneId)
  2. Domain names exist but certificate generation fails due to DNS setup issues or other errors
  3. Domain names exist but the deployment is not yet finished

Solution

Added a hasDomains check that scans the compose project to determine if any domain names actually exist. The function now handles two distinct scenarios when cnt == 0:

  1. No domains exist (!hasDomains): Shows "No domainname found in compose file; no HTTPS cert generation needed"
  2. Domains exist but not processed (hasDomains): Shows "Deployment may not be finished yet; please wait and try again"

This ensures users receive accurate feedback about why certificate generation isn't proceeding, whether it's due to truly missing domain names or an incomplete deployment.

Changes

  • Modified GenerateLetsEncryptCert() in src/pkg/cli/cert.go to add domain detection logic and differentiate between missing domains vs incomplete deployments
  • Added TestHasDomains() test to validate the domain detection functionality
  • Preserved all existing behavior while eliminating the misleading message and adding helpful deployment status feedback

Linked Issues

Fixes #1476

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
Original prompt

This section details on the original issue you should resolve

<issue_title>Bad error message for defang cert gen</issue_title>
<issue_description>Ran into an issue with acme lambda, and then got the following error when running defang cert gen:

No `domainname` found in compose file; no HTTPS cert generation needed

This was misleading, because it wasn't actually the issue and was confusing because there were clearly domain names in the compose file.</issue_description>

<agent_instructions>The existing message should only be printed if it's true, ie. no services with domainnames. Otherwise, the actual error must be surfaced.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1476

💡 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.

Copilot AI changed the title [WIP] Bad error message for defang cert gen Fix misleading error message in cert generation when domains exist but cert generation fails Oct 3, 2025
Copilot AI requested a review from lionello October 3, 2025 21:30
}
if cnt == 0 {
// Only show the "no domainname found" message if there truly are no domains in the compose file
if cnt == 0 && !hasDomains {
Copy link
Member

Choose a reason for hiding this comment

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

Need to handle both cases: if cnt == 0 && hasDomains then the deployment is probably not finished.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot see above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in commit d7405be. The code now handles both cases when cnt == 0:

  • No domains: Shows "No domainname found" message
  • Domains exist: Shows "Deployment may not be finished yet; please wait and try again"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Added handling for the case when cnt == 0 && hasDomains to inform the user that the deployment may not be finished yet. Changes in commit d7405be.

}
if cnt == 0 {
// Only show the "no domainname found" message if there truly are no domains in the compose file
if cnt == 0 && !hasDomains {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot see above

When domains exist but no cert generation was processed (cnt == 0 && hasDomains),
inform the user that the deployment may not be finished yet instead of staying silent.

Co-authored-by: raphaeltm <[email protected]>
Copilot AI changed the title Fix misleading error message in cert generation when domains exist but cert generation fails Fix misleading error message in cert generation and add deployment status feedback Nov 26, 2025
Copilot AI requested a review from raphaeltm November 26, 2025 18:29
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.

Bad error message for defang cert gen

3 participants