overleaf/overleaf · error · Errors.NotFoundError

Cannot archive split test with ID '${name}': not found

Error message

Cannot archive split test with ID '${name}': not found

What it means

Thrown by SplitTestManager.archive when no split test exists with the given name. The manager first loads the test with getSplitTest({ name }) and throws Errors.NotFoundError if the lookup returns null/undefined. Archiving is only valid for an existing, currently-unarchived test.

Source

Thrown at services/web/app/src/Features/SplitTests/SplitTestManager.mjs:414

        variant.userCount = correspondingVariant.userCount
      }
    }
  } else {
    for (const variant of previousVersionCopy.variants) {
      if (variant.userCount) {
        variant.userCount = 0
      }
    }
  }

  splitTest.versions.push(previousVersionCopy)
  return _saveSplitTest(splitTest)
}

async function archive(name, userId) {
  const splitTest = await getSplitTest({ name })
  if (!splitTest) {
    throw new Errors.NotFoundError(
      `Cannot archive split test with ID '${name}': not found`
    )
  }
  if (splitTest.archived) {
    throw new Errors.InvalidError(
      `Split test with ID '${name}' is already archived`
    )
  }
  splitTest.archived = true
  splitTest.archivedAt = new Date()
  splitTest.archivedBy = userId
  return _saveSplitTest(splitTest)
}

async function clearCache() {
  await CacheFlow.reset('split-test')
}

View on GitHub (pinned to 28ad3b03b7)

Solutions

  1. Verify the split test name exists via getSplitTest({ name }) or an admin listing before calling archive.
  2. Check you are connected to the intended database/environment (staging vs production).
  3. Fix casing/typos in the name — names are matched exactly.
  4. Catch Errors.NotFoundError and return a 404 with a message identifying the missing split test name.

Example fix

// before
await SplitTestManager.promises.archive('saplit-test', userId) // typo
// after
const splitTest = await SplitTestManager.promises.getSplitTest({ name: 'saplit-test' })
if (!splitTest) throw new Errors.NotFoundError({ message: 'no such split test' })
await SplitTestManager.promises.archive('saplit-test', userId)
Defensive patterns

Strategy: validation

Validate before calling

const splitTest = await SplitTestManager.promises.getSplitTest({ name })
if (!splitTest) throw new Error(`split test '${name}' does not exist in this environment`)

Type guard

function splitTestExists(result) {
  return result != null && typeof result === 'object' && typeof result.name === 'string'
}

Try / catch

try {
  await SplitTestManager.promises.archive(name, userId)
} catch (err) {
  if (err instanceof Errors.NotFoundError) {
    // return 404 with the offending name
  } else throw err
}

Prevention

When it happens

Trigger: Calling archive(name, userId) where name does not match any persisted split test (typo, test deleted, wrong environment/database, or test referenced from config that was never synced to the DB).

Common situations: Typo in the split test name; running against a staging DB while the test only exists in production (or vice versa); a test removed from the splitTests collection but still referenced by cached feature-flag config; case mismatch in the name.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03). Data as JSON: /api/errors/9d1a04b80a6d1ff5. Report an issue: GitHub.