badges/shields · error · NotFound

not found

Error message

not found

What it means

The Ansible role service fetches role metadata from the Ansible Galaxy API and throws NotFound with prettyMessage 'not found' when the response's results array is empty. This is Shields' way of rendering a 'not found' badge when the requested namespace/name does not match any role on Galaxy.

Source

Thrown at services/ansible/ansible-role.service.js:46

      },
    },
  }

  static defaultBadgeData = { label: 'role downloads' }

  async fetch({ namespace, name }) {
    const url = 'https://galaxy.ansible.com/api/v1/roles/'
    return this._requestJson({
      url,
      schema: ansibleRoleSchema,
      options: { searchParams: { namespace, name, limit: 1 } },
    })
  }

  async handle({ namespace, name }) {
    const json = await this.fetch({ namespace, name })
    if (json.results.length === 0) {
      throw new NotFound({ prettyMessage: 'not found' })
    }
    return renderDownloadsBadge({ downloads: json.results[0].download_count })
  }
}

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. Verify the namespace/name in the badge URL against the role's page on galaxy.ansible.com.
  2. Check whether the role was renamed or removed from Galaxy.
  3. Wait for the Galaxy import to complete for newly published roles.
  4. Use the correct namespace (author) — role names are not unique across namespaces.

Example fix

// before
/api/v1/roles/?namespace__name=myusr&name=myrole  -> results: [] -> NotFound
// after (correct namespace)
/api/v1/roles/?namespace__name=correctuser&name=myrole  -> results: [{ download_count: 42 }]
Defensive patterns

Strategy: validation

Validate before calling

// verify the role exists before requesting the badge
curl -s "https://galaxy.ansible.com/api/v1/roles/?namespace__name=NS&name=NAME" | jq '.results | length'

Type guard

function roleExists(json) { return Array.isArray(json?.results) && json.results.length > 0 }

Try / catch

try {
  const badge = await service.handle({ namespace, name })
} catch (err) {
  if (err.name === 'NotFound') return renderNotFoundBadge()
  throw err
}

Prevention

When it happens

Trigger: this.fetch({ namespace, name }) succeeds (HTTP 200) but json.results.length === 0 — the Galaxy search by namespace/name returns no matching role.

Common situations: Typo in the role namespace or name in the badge URL, role deleted/renamed on Ansible Galaxy, role not yet published/imported (Galaxy import pending), asking for a role hosted under a different namespace.

Related errors


AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30). Data as JSON: /api/errors/4c182ecc1a672138. Report an issue: GitHub.