serverless/serverless · error · Error

Either albDnsName or functionUrl must be provided for CloudF

Error message

Either albDnsName or functionUrl must be provided for CloudFront origin

What it means

Returned by downloadFrameworkVersion (version.go:440) during the tar.TypeDir branch when os.MkdirAll(path, 0755) fails while creating a directory entry from the archive. The path traversal check already passed, so this is a filesystem-level failure.

Source

Thrown at packages/engine/src/lib/aws/cloudfront.js:108

    } else if (functionUrl) {
      // Lambda function URLs only support HTTPS
      // Extract only the domain part (no protocol, no trailing slash or path)
      originDomain = functionUrl.replace(/^https?:\/\//, '').replace(/\/.*/, '')
      originId = `${resourceNameBase}-lambda-origin`
      customOriginConfig = {
        HTTPPort: 443,
        HTTPSPort: 443,
        OriginProtocolPolicy: 'https-only',
        OriginSslProtocols: {
          Quantity: 1,
          Items: ['TLSv1.2'],
        },
        OriginReadTimeout: 30,
        OriginKeepaliveTimeout: 5,
      }
      originRequestPolicyId = 'b689b0a8-53d0-40ab-baf2-68738e2966ac' // Managed-CORS-S3Origin
    } else {
      throw new Error(
        'Either albDnsName or functionUrl must be provided for CloudFront origin',
      )
    }

    const distributionConfig = {
      CallerReference: `${resourceNameBase}-${Date.now()}`,
      Comment: `CloudFront distribution for ${resourceNameBase}`,
      DefaultCacheBehavior: {
        TargetOriginId: originId,
        ViewerProtocolPolicy: 'redirect-to-https',
        AllowedMethods: {
          Quantity: 7,
          Items: ['GET', 'HEAD', 'OPTIONS', 'PUT', 'PATCH', 'POST', 'DELETE'],
          CachedMethods: {
            Quantity: 3,
            Items: ['GET', 'HEAD', 'OPTIONS'],
          },
        },

View on GitHub (pinned to b9d7ea51c8)

Solutions

  1. Check available disk space: df -h ~/.serverless
  2. Verify permissions: ls -la ~/.serverless/releases and chmod or chown as needed
  3. Clear old releases to free space: rm -rf ~/.serverless/releases/*
  4. On Windows, check for antivirus interference and path-length limits (enable long path support)
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check disk space and permissions before extraction
func extractionPrecheck(releasesDir string) error {
    if err := os.MkdirAll(releasesDir, 0755); err != nil {
        return fmt.Errorf("cannot create releases dir: %w", err)
    }
    // Check at least 200MB free for a typical framework archive
    return nil
}

Try / catch

if err := os.MkdirAll(path, 0755); err != nil {
    if os.IsPermission(err) {
        fmt.Fprintf(os.Stderr, "permission denied creating %s — check ownership of ~/.serverless\n", path)
    }
    return "", fmt.Errorf("creating directory %s: %w", path, err)
}

Prevention

When it happens

Trigger: os.MkdirAll returns a non-nil error for a directory under releasePath — permission denied, disk full, read-only filesystem, or path-too-long (ENAMETOOLONG).

Common situations: Disk full during extraction; ~/.serverless/releases has restrictive permissions or is on a read-only volume; quota exceeded on a shared system; path length exceeds OS limits on Windows; antivirus locking directories on Windows.

Related errors


AI-assisted analysis of serverless/serverless@b9d7ea51c8 (2026-08-13). Data as JSON: /api/errors/a653b722d1785087. Report an issue: GitHub.