{"record":{"id":"554b5de6e48bb652","repo":"withastro/astro","slug":"entry-collection-lookupid-was-not-found","errorCode":null,"errorMessage":"Entry ${collection} → ${lookupId} was not found.","messagePattern":"Entry (.+?) → (.+?) was not found\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/content/runtime.ts","lineNumber":215,"sourceCode":"\n\t\tif (collection in liveCollections) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.UnknownContentCollectionError,\n\t\t\t\tmessage: `Collection \"${collection}\" is a live collection. Use getLiveEntry() instead of getEntry().`,\n\t\t\t});\n\t\t}\n\t\tif (typeof lookupId === 'object') {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.UnknownContentCollectionError,\n\t\t\t\tmessage: `The entry identifier must be a string. Received object.`,\n\t\t\t});\n\t\t}\n\t\tconst store = await globalDataStore.get();\n\n\t\tif (await store.hasCollection(collection)) {\n\t\t\tconst entry = await store.get<DataEntry>(collection, lookupId);\n\t\t\tif (!entry) {\n\t\t\t\tlogger.warn('content', `Entry ${collection} → ${lookupId} was not found.`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// @ts-expect-error\tvirtual module\n\t\t\tconst { default: imageAssetMap } = await import('astro:asset-imports');\n\t\t\tconst data = resolveEntryData(entry, imageAssetMap);\n\t\t\tconst result = {\n\t\t\t\t...entry,\n\t\t\t\tdata,\n\t\t\t\tcollection,\n\t\t\t} as DataEntryResult | ContentEntryResult;\n\t\t\t// TODO: remove in Astro 8\n\t\t\twarnForPropertyAccess(\n\t\t\t\tlogger,\n\t\t\t\tresult.data,\n\t\t\t\t'slug',\n\t\t\t\t`[content] Attempted to access deprecated property on \"${collection}\" entry.\\nThe \"slug\" property is no longer automatically added to entries. Please use the \"id\" property instead.`,\n\t\t\t);","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/content/runtime.ts#L197-L233","documentation":"getEntry(collection, lookupId) found the collection but no entry with that id; Astro logs this warning and returns undefined. Note the API accepts ids and, for content entries, slugs — passing an object as the identifier is a separate hard error above this branch, but a stale or wrong string only yields undefined plus this warning, which frequently surfaces later as a TypeError on the undefined result.","triggerScenarios":"Looking up a hard-coded slug/id that was renamed or deleted; confusing data-entry ids with content-entry slugs; entries whose frontmatter slug differs from the filename so the wrong key is passed.","commonSituations":"Renaming files or slugs breaking getEntry calls scattered through pages; lookups driven by URL params or CMS data; dynamic routes whose param values drift from actual entry ids.","solutions":["Use the current id/slug — run astro sync and rely on generated types to flag stale references at compile time","Guard the undefined result before accessing properties","For dynamic routes, derive lookups from getStaticPaths so the ids always exist"],"exampleFix":"// before\nconst post = await getEntry('blog', 'old-slug');\nconst { data } = post; // TypeError when undefined\n\n// after\nconst post = await getEntry('blog', 'new-slug');\nif (!post) return null;\nconst { data } = post;","handlingStrategy":"type-guard","validationCode":"// For dynamic routes, validate ids against the store before lookup\nconst entries = await getCollection('blog');\nconst ids = new Set(entries.map((e) => e.id));\nif (!ids.has(lookupId)) {\n  return Astro.redirect('/404');\n}","typeGuard":"type ContentEntryLike = { id: string; slug: string };\nfunction isEntry<T extends ContentEntryLike>(entry: T | undefined): entry is T {\n  return entry !== undefined;\n}\n// usage:\nconst post = await getEntry('blog', slug);\nif (!isEntry(post)) return Astro.redirect('/404');","tryCatchPattern":null,"preventionTips":["Prefer getEntries with ids from getStaticPaths so lookups cannot drift","Always branch on the undefined return of getEntry before property access","Run astro sync and use generated entry types to catch stale slugs at compile time"],"tags":["astro","content-collections","get-entry","not-found","runtime"],"backgroundTag":"content-entry-not-found","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-09-09T03:35:40.650Z","contentChangedAt":"2026-09-09T03:35:40.650Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}