badges/shields · error · NotFound

module not found

Error message

module not found

What it means

The OPM (OpenResty Package Manager) version service issues a request expecting the server to respond with a 302 redirect whose Location URL ends in `<moduleName>-<version>.opm`. If there is no redirect location (`res.redirectUrls[0]` is empty), it throws NotFound — meaning the module/user path did not resolve to a downloadable module on luarocks/opm.

Source

Thrown at services/opm/opm-version.service.js:52

  async fetch({ user, moduleName }) {
    const { res } = await this._request({
      url: 'https://opm.openresty.org/api/pkg/fetch',
      options: {
        method: 'HEAD',
        searchParams: {
          account: user,
          name: moduleName,
        },
      },
      httpErrors: {
        404: 'module not found',
      },
    })

    // TODO: set followRedirect to false and intercept 302 redirects
    const location = res.redirectUrls[0].toString()
    if (!location) {
      throw new NotFound({ prettyMessage: 'module not found' })
    }
    const version = location.match(`${moduleName}-(.+).opm`)[1]
    if (!version) {
      throw new InvalidResponse({ prettyMessage: 'version invalid' })
    }
    return version
  }

  async handle({ user, moduleName }) {
    const version = await this.fetch({ user, moduleName })

    return renderVersionBadge({ version })
  }
}

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. Verify the module name and user namespace on the opm/luarocks site and correct the badge URL.
  2. Check whether the module still exists upstream; republish or pick a maintained alternative.
  3. Manually curl -I the opm module URL to see if a 302 Location header is returned; if the server behavior changed, the service may need updating.
  4. Use the exact rock name including correct hyphenation.

Example fix

// before
GET /opm/v/bungle/lua-resty-template-missing.json
// after
GET /opm/v/bungle/lua-resty-template.json
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the opm module resolves with a redirect before requesting the badge
const res = await fetch(`https://opm.openresty.org/api/pkg/individual/${user}/${moduleName}`, { redirect: 'manual' })
if (res.status !== 302 || !res.headers.get('location')) {
  throw new Error(`OPM module ${user}/${moduleName} not found`)
}

Type guard

function hasRedirect(res) {
  return res.redirectUrls && res.redirectUrls.length > 0 &&
    Boolean(res.redirectUrls[0])
}

Try / catch

try {
  const version = await getOpmVersion(user, moduleName)
} catch (e) {
  if (e.message === 'module not found') {
    // show fallback badge or remove it from the README
  } else { throw e }
}

Prevention

When it happens

Trigger: Calling the OPM version badge with a user/moduleName combination for which the opm server issues no redirect: nonexistent module, wrong user namespace, or the server responding 200 without redirecting.

Common situations: Modules removed from opm/luarocks.org; misspelled rock names (hyphen vs underscore); API changes on opm server causing it to stop redirecting (the code even notes a TODO around redirect handling).

Related errors


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