Skip to content

0.26.7: NoMethodError in inject_app when APTIBLE_OUTPUT_FORMAT=json and app has no Docker settings #416

@hjhart

Description

@hjhart

Bug

aptible apps --environment <env> crashes in v0.26.7 when APTIBLE_OUTPUT_FORMAT=json is set and any app in the environment has never had Docker credentials configured (e.g. git-deployed apps like a Cloudflare tunnel or Datadog agent).

This breaks aptible/aptible-deploy-action, which uses APTIBLE_OUTPUT_FORMAT=json aptible apps as a pre-check before deploying.

For us at Clarity Pediatrics, this is breaking our deploys to our production environment but not our staging environment because we used git deploys for three of our apps in that environment. More information below.

Error

/opt/aptible-toolbelt/embedded/lib/ruby/gems/2.3.0/gems/aptible-cli-0.26.7/lib/aptible/cli/resource_formatter.rb:129:in `inject_app': undefined method `[]' for nil:NilClass (NoMethodError)
	from .../aptible/cli/subcommands/apps.rb:30:in `block (5 levels) in apps'
	...
Could not find app web-app in <environment>

Root cause

In apps.rb, the JSON branch calls current_setting(app) for every app and passes the result to inject_app:

# apps.rb
if Renderer.format == 'json'
  accounts.each do |account|
    account.each_app do |app|
      node.object do |n|
        setting = current_setting(app)
        ResourceFormatter.inject_app(n, app, account, setting)
      end
    end
  end

In resource_formatter.rb, inject_app guards against setting being nil — but not against setting.settings being nil:

# resource_formatter.rb ~line 125
unless setting.nil?
  node.value('docker_image',
             setting.settings['APTIBLE_DOCKER_IMAGE'])           # ← crash: setting.settings is nil
  node.value('private_registry_username',
             setting.sensitive_settings['APTIBLE_PRIVATE_REGISTRY_USERNAME'])
  node.value('private_registry_password',
             setting.sensitive_settings['APTIBLE_PRIVATE_REGISTRY_PASSWORD'])
end

current_setting(app) returns a non-nil object for all apps, but .settings is nil for apps that have no Docker image configured (git-deployed apps). This was introduced in 0.26.7 — the JSON output for aptible apps did not include docker_image/private_registry_* fields in 0.26.6.

Fix

Add safe navigation:

unless setting.nil?
  node.value('docker_image',
             setting.settings&.[]('APTIBLE_DOCKER_IMAGE'))
  node.value('private_registry_username',
             setting.sensitive_settings&.[]('APTIBLE_PRIVATE_REGISTRY_USERNAME'))
  node.value('private_registry_password',
             setting.sensitive_settings&.[]('APTIBLE_PRIVATE_REGISTRY_PASSWORD'))
end

Environment

  • aptible-cli 0.26.7 (released 2026-06-08, does not reproduce on 0.26.6)
  • Triggered via aptible/aptible-deploy-action which sets APTIBLE_OUTPUT_FORMAT=json
  • Any environment containing a mix of Docker-deployed and git-deployed apps

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions