Skip to content

Legal API - a rejected or validate-only one-call business creation leaves a temporary business behind #35637

Todo

Description

@benjamin-bc-gov

What happens

POST /businesses without draft=true creates the temporary business (T number) and links it to the account in auth (create_bootstrap + register_bootstrap). Then it calls saving_filings and doesn't check the result. If the request stops before the filing is saved, the T number and the account link stay but no filing exists. That happens when:

  • only_validate=true was sent (returns 200 before the save)
  • validation fails (400)
  • the basic checks or authorization checks reject it
  • save_filing raises (the exception is only logged, so the request probably ends in a 500)

Out of scope: payment failures. The filing is saved before the invoice is created, so a refused payment leaves a normal draft that can be opened and deleted.

What the customer sees

A T number draft in My Business Registry for a business that was never created. It can't be opened because there's no filing behind it. It can't be removed either: for temporary types, the dashboard's removeBusiness calls GET /businesses/{T}/filings first, gets a 404, and stops before the removeAffiliation fallback. Staff have to clean these up by hand.

How to reproduce

On dev with an API account, send POST /businesses?only_validate=true with a valid incorporation body. You get a 200 and nothing is saved, but the account now shows a new T number draft that can't be opened or removed. An invalid one-call body (400) does the same.

Scope / history

From late July until the #35543 fix (lear fae6e2964, 7047af223), every one-call request was rejected by the identifier check after the T number had been created, so every attempt left one of these behind. That includes the 16 sandbox requests run on dev on 2026-11-06. With #35543 fixed, new ones still come from every only_validate=true call and every rejected one-call request.

Ask

  1. A rejected or validation-only one-call creation should leave nothing behind.
  2. The leftovers created since July should be cleaned up.

Plan:

  1. Code fix so new ones can't happen (35637 Legal API - rejected or validate-only business creation leaves a temporary business behind lear#4999): post_businesses removes the T number and its account affiliation (deregister_bootstrap + delete_bootstrap) when the request ends without a filing saved against it. A filing saved before a later failure (eg: payment) keeps its T number.

Technical notes

  • legal-api/src/legal_api/resources/v2/business/business.py, post_businesses: create_bootstrap, then register_bootstrap, then return saving_filings(...) with no status check. The @TODO rollback bootstrap comment is already there.
  • business_filings.py, saving_filings: the only_validate and validation-error returns happen before save_filing. Payment (complete_filing → create_invoice) runs after the save.
  • business_filings.py, delete_filings: this is the only place deregister_bootstrap + delete_bootstrap are called, and it needs a filing id.
  • business-ui/web/business-registry-dashboard/app/stores/affiliations.ts, removeBusiness: for TMP/ATMP/RTMP/CTMP types it requires a filing response before it does anything.
  • Nothing in gcp-jobs currently cleans up registration_bootstraps.

Activity

  1. added
    bug
    Entities Team
    on Nov 16, 2026
  2. self-assigned this
    on Nov 26, 2026
  3. mruff-aeq commented on Nov 26, 2026

    @mruff-aeq
    Collaborator

    Reproduced on dev. Both of these calls left a T number linked to the account with no filing behind it, so it can't be opened or removed from the dashboard:

    POST /businesses?only_validate=true        (valid numbered IA)
      -> 200, response has T number TXmYKxm1KT
    GET  /businesses/TXmYKxm1KT/filings        -> 404 "TXmYKxm1KT no filings found"
    auth GET /entities/TXmYKxm1KT              -> 200, affiliated to org 3040
    
    POST /businesses                           (IA with offices removed)
      -> 422 "'offices' is a required property", response has T number Tz77sRGKm5
    GET  /businesses/Tz77sRGKm5/filings        -> 404 "Tz77sRGKm5 no filings found"
    auth GET /entities/Tz77sRGKm5              -> 200, affiliated to org 3040
    

    Schema errors come back as 422 btw, not 400. Those 2 T numbers can be used to test the cleanup once it's in.

  4. self-assigned this
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Entities Teamapibug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions