pulumi/pulumi · error

failed to get logs: %w

Error message

failed to get logs: %w

What it means

Wraps any error from backend.GetStackLogs, which queries the backend/engine for the stack's operation logs via operations.LogQuery (start time, resource filter). Failures include backend communication errors, the stack's operation log being missing or unreadable, or decryption failures on log entries.

Source

Thrown at pkg/cmd/pulumi/logs/logs.go:137

					s.Ref().String(),
					cmd.FormatTime(*startTime),
				)
			}

			// IDEA: This map will grow forever as new log entries are found.  We may need to do a more approximate
			// approach here to ensure we don't grow memory unboundedly while following logs.
			//
			// Note: Just tracking latest log date is not sufficient - as stale logs may show up which should have been
			// displayed before previously rendered log entries, but weren't available at the time, so still need to be
			// rendered now even though they are technically out of order.
			shown := map[operations.LogEntry]bool{}
			for {
				logs, err := backend.GetStackLogs(ctx, secrets.DefaultProvider, s, cfg, operations.LogQuery{
					StartTime:      startTime,
					ResourceFilter: resourceFilter,
				})
				if err != nil {
					return fmt.Errorf("failed to get logs: %w", err)
				}

				// When we are emitting a fixed number of log entries, and outputting JSON, wrap them in an array.
				if !follow && jsonOut {
					entries := slice.Prealloc[logEntryJSON](len(logs))

					for _, logEntry := range logs {
						if _, shownAlready := shown[logEntry]; !shownAlready {
							eventTime := time.Unix(0, logEntry.Timestamp*1000000)

							entries = append(entries, logEntryJSON{
								ID:        logEntry.ID,
								Timestamp: cmd.FormatTime(eventTime.UTC()),
								Message:   logEntry.Message,
							})

							shown[logEntry] = true
						}

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Deploy the stack at least once (`pulumi up`) so an operations log exists.
  2. Check backend connectivity and credentials (`pulumi whoami`, re-run `pulumi login`).
  3. Verify the --resource value matches a real resource URN from the stack.
  4. Retry if the wrapped cause indicates a transient network/API error.
  5. Inspect the wrapped error for decryption issues and fix the secrets provider.

Example fix

// before
pulumi logs --stack dev   # backend unreachable
// after
pulumi logout && pulumi login
pulumi logs --stack dev
Defensive patterns

Strategy: retry

Validate before calling

// Shell: ensure backend auth and stack has updates before fetching logs
pulumi whoami >/dev/null || { echo "not logged in" >&2; exit 1; }
pulumi stack history --stack "$STACK" | grep -q . || { echo "no deployments yet" >&2; exit 1; }

Try / catch

// Retry transient backend failures with backoff
for i in 1 2 3; do
  out, err := exec.Command("pulumi", "logs", "--stack", stack).CombinedOutput()
  if err == nil { break }
  if !strings.Contains(string(out), "failed to get logs") { log.Fatal(string(out)) }
  time.Sleep(time.Duration(i) * 2 * time.Second)
}

Prevention

When it happens

Trigger: Running `pulumi logs` (with --follow or one-shot) when the backend (cloud or local) fails to return logs: no operations log exists for the stack, network/API errors to the service, or the LogQuery can't be served for the resource filter given via --resource.

Common situations: Querying logs for a stack never deployed (no update records); offline use of a cloud backend; --resource ARN/URN typo; expired cloud credentials; secrets provider failing while decrypting log values.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/2d355a6f0899493c. Report an issue: GitHub.