Skip to content

Inconsistent stack name resolution between resource discovery and deploy command #484

@seanspeaks

Description

@seanspeaks

Description

The getStackName() function in the deploy command lacks the fallback logic that resource discovery uses, causing post-deployment health checks to fail even when deployment succeeds.

Current Behavior

During Deployment (Resource Discovery):

// packages/devtools/infrastructure/domains/shared/resource-discovery.js (lines 91-92)
const stackName = `${appDefinition.name || 'create-frigg-app'}-${stage}`;
const serviceName = appDefinition.name || 'create-frigg-app';
  • Has hardcoded fallback to 'create-frigg-app'
  • Works even when appDefinition.name is undefined
  • Result: Stack found successfully ✅

During Health Check (Post-Deploy):

// packages/devtools/frigg-cli/deploy-command/index.js (lines 190-212)
function getStackName(appDefinition, options) {
    if (appDefinition?.name) {
        return `${appDefinition.name}-${stage}`;
    }
    
    const infraModule = require(infraPath);
    if (infraModule.service) {
        return `${infraModule.service}-${stage}`;
    }
    
    return null;  // ← NO FALLBACK
}
  • No fallback logic
  • Returns null when appDefinition.name is undefined
  • Result: Health check skipped ⚠️

Impact

When appDefinition.name is not explicitly defined:

  1. Deployment succeeds (uses fallback name)
  2. Stack is created/updated as create-frigg-app-{stage}
  3. Post-deploy health check can't determine stack name
  4. Health check is skipped with warning:
    ⚠️ Could not determine stack name - skipping health check
    Run "frigg doctor <stack-name>" manually to check stack health
    

Reproduction

  1. Create appDefinition without name property:

    const appDefinition = {
        integrations: [MyIntegration],
        // name: 'my-app',  // ← Not defined
        vpc: { enable: true },
        // ...
    };
  2. Run deployment:

    frigg deploy --stage production
  3. Observe output:

    ✔ Service deployed to stack create-frigg-app-production (333s)
    ✓ Deployment completed successfully!
    ⚠️ Could not determine stack name - skipping health check
    

Proposed Fix

Option 1: Add same fallback to getStackName():

function getStackName(appDefinition, options) {
    const stage = options.stage || 'dev';
    
    if (appDefinition?.name) {
        return `${appDefinition.name}-${stage}`;
    }
    
    // Try infrastructure.js
    const infraPath = path.join(process.cwd(), PATHS.INFRASTRUCTURE);
    if (fs.existsSync(infraPath)) {
        try {
            const infraModule = require(infraPath);
            if (infraModule.service) {
                return `${infraModule.service}-${stage}`;
            }
        } catch (error) {
            // Ignore
        }
    }
    
    // Fallback to default (same as resource discovery)
    return `create-frigg-app-${stage}`;
}

Option 2: Extract shared stack name resolution logic to a utility function used by both.

Files Affected

  • packages/devtools/infrastructure/domains/shared/resource-discovery.js (line 91-92)
  • packages/devtools/frigg-cli/deploy-command/index.js (line 190-212)

Environment

  • Frigg version: 2.0.0--canary.482.bda352c.0
  • Node version: 20.x
  • Deployment: GitHub Actions / AWS Lambda

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions