#13501·paperclip

Company-ref resolution middleware 404s the /companies/import/* API routes

Author: casarod5Created Sep 15, 2026Updated Sep 16, 2026

Symptom

On 2026.817.0, every CLI import (paperclipai company import <pkg>) fails immediately:

API error 404: Company not found: 'import'

Root cause

The short-company-reference middleware added for issue-prefix resolution (resolve GRA/uuid-prefix refs to the full company uuid before company-scoped routes run) matches /companies/<ref>/... for ANY non-uuid first segment. /companies/import/preview, /import/apply and /import/jobs/:id therefore treat import as a company reference, find no company, and return 404 before the real import routes are reached.

Suggested fix

Pass through when the first segment is a reserved word (e.g. import), or make the resolver only rewrite when the reference resolves to exactly one company and call next() otherwise.

Workaround

We ship a local dist patch that skips resolution when ref === "import".