{"record":{"id":"efec951d62dbc948","repo":"apify/crawlee","slug":"the-body-property-is-not-available-skipnaviga","errorCode":null,"errorMessage":"The `body` property is not available - `skipNavigation` was used","messagePattern":"The `body` property is not available - `skipNavigation` was used","errorType":"exception","errorClass":"NavigationSkippedError","httpStatus":null,"severity":"error","filePath":"packages/cheerio-crawler/src/internals/cheerio-crawler.ts","lineNumber":248,"sourceCode":"        try {\n            const isXml = crawlingContext.contentType.type.includes('xml');\n            const body = Buffer.isBuffer(crawlingContext.body)\n                ? crawlingContext.body.toString(crawlingContext.contentType.encoding)\n                : crawlingContext.body;\n            const dom = parseDocument(body, { decodeEntities: true, xmlMode: isXml });\n            const $ = cheerio.load(dom, {\n                xml: { decodeEntities: true, xmlMode: isXml },\n            } as CheerioOptions);\n\n            return {\n                $,\n                body,\n            };\n        } catch (err) {\n            if (err instanceof NavigationSkippedError) {\n                return {\n                    get body(): string {\n                        throw new NavigationSkippedError(\n                            'The `body` property is not available - `skipNavigation` was used',\n                            { cause: err },\n                        );\n                    },\n                    get $(): CheerioAPI {\n                        throw new NavigationSkippedError(\n                            'The `$` property is not available - `skipNavigation` was used',\n                            { cause: err },\n                        );\n                    },\n                };\n            }\n\n            throw err;\n        }\n    }\n\n    private async addHelpers(crawlingContext: InternalHttpCrawlingContext & { $: CheerioAPI }) {","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/cheerio-crawler/src/internals/cheerio-crawler.ts#L230-L266","documentation":"Crawlee's CheerioCrawler lets a request handler opt out of downloading the response body via `skipNavigation`. When that option is used, the `body` property of the crawling context is replaced with a getter that throws NavigationSkippedError on access, because no body was ever fetched.","triggerScenarios":"Accessing `crawlingContext.body` (or destructuring `{ body }` from the context) inside a requestHandler while the crawler/request was configured with `skipNavigation: true`.","commonSituations":"Switching a crawler to `skipNavigation` for speed and forgetting that old handler code still reads `body`; copying handler code between a CheerioCrawler with and without skipNavigation.","solutions":["Stop reading `body` in the handler when skipNavigation is enabled; rely on `request.url`, response headers, or enqueue links only.","Remove `skipNavigation: true` from the crawler options if the response body is actually needed.","Guard access: check a `skipNavigation` flag on the crawler options before touching `body`."],"exampleFix":"// before\nconst crawler = new CheerioCrawler({ skipNavigation: true, requestHandler: ({ body }) => { parse(body); } });\n// after\nconst crawler = new CheerioCrawler({ skipNavigation: true, requestHandler: ({ request, enqueueLinks }) => { enqueueLinks(); } });","handlingStrategy":"validation","validationCode":"if (crawlerOptions.skipNavigation) { throw new Error('handler reads `body` but skipNavigation is enabled'); }","typeGuard":"function hasBody(ctx: object): ctx is { body: string } { return 'body' in ctx && !isNavigationSkipped(ctx); }","tryCatchPattern":"try { use(context.body); } catch (err) { if (err instanceof NavigationSkippedError) { /* handle missing body */ } else { throw err; } }","preventionTips":["Keep skipNavigation crawlers' handlers free of body/$ access","Don't share one request handler between parsing and navigation-only crawlers","Destructure only the context fields you know exist for the configured options"],"tags":["cheerio-crawler","skip-navigation","api-misuse"],"backgroundTag":"property-unavailable-when-option-disabled","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}