When the trace files shows duplicate Web.Content which might be triggered by some operations down the Power Query pipeline, it is a good idea to Buffer the Web.Contents first
This example demonstrates a defensive Power Query pattern for handling duplicate `Web.Contents` calls in trace files, which can arise from downstream pipeline operations. The code defines a custom function, `Web.BufferedContents.m`, that buffers the binary response using `Binary.Buffer` and captures metadata via `Value.Metadata` to inspect the HTTP status. It explicitly handles 404 responses by returning `null` instead of an error, using the `ManualStatusHandling={404}` option to prevent automatic error propagation. The function wraps `Web.Contents` with buffering to improve performance when the same URL is requested multiple times, while also ensuring status codes are checked. This approach is particularly useful in ETL scenarios where repeated web requests can be triggered by later query steps.
AI-generated description