{"record":{"id":"99555dca3fedd5cb","repo":"GoogleChrome/lighthouse","slug":"need-at-least-one-step-before-getting-the-result","errorCode":null,"errorMessage":"Need at least one step before getting the result","messagePattern":"Need at least one step before getting the result","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/user-flow.js","lineNumber":316,"sourceCode":" * @param {LH.UserFlow.GatherStep[]} gatherSteps\n * @return {string}\n */\nfunction getFlowName(name, gatherSteps) {\n  if (name) return name;\n\n  const firstArtifacts = gatherSteps[0].artifacts;\n  const {locale} = firstArtifacts.settings;\n  const url = new URL(firstArtifacts.URL.finalDisplayedUrl).hostname;\n  return translate(UIStrings.defaultFlowName, {url}, locale);\n}\n\n/**\n * @param {Array<LH.UserFlow.GatherStep>} gatherSteps\n * @param {{name?: string, config?: LH.Config, gatherStepRunnerOptions?: GatherStepRunnerOptions}} options\n */\nasync function auditGatherSteps(gatherSteps, options) {\n  if (!gatherSteps.length) {\n    throw new Error('Need at least one step before getting the result');\n  }\n\n  /** @type {LH.FlowResult['steps']} */\n  const steps = [];\n  for (const gatherStep of gatherSteps) {\n    const {artifacts, flags} = gatherStep;\n    const name = getStepName(flags, artifacts);\n\n    let runnerOptions = options.gatherStepRunnerOptions?.get(gatherStep);\n\n    // If the gather step is not active, we must recreate the runner options.\n    if (!runnerOptions) {\n      // Step specific configs take precedence over a config for the entire flow.\n      const config = options.config;\n      const {gatherMode} = artifacts.GatherContext;\n      const {resolvedConfig} = await initializeConfig(gatherMode, config, flags);\n      runnerOptions = {\n        resolvedConfig,","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/user-flow.js#L298-L334","documentation":"Thrown by auditGatherSteps() when the gather steps array is empty. This function is called by createFlowResult() and generateReport() to audit collected steps and produce the final flow result. At least one completed step (navigation, timespan, or snapshot) must exist before requesting results — an empty flow has nothing to audit.","triggerScenarios":"Calling flow.createFlowResult() or flow.generateReport() without having added any steps via navigate(), startTimespan()/endTimespan(), or snapshot(). Also reachable when calling auditGatherSteps directly with an empty array (e.g., from createArtifactsJson output with no gatherSteps).","commonSituations":"Empty flow — created a UserFlow but never added steps. Conditional logic that skipped all step calls (e.g., a loop that didn't iterate). Loading artifacts from createArtifactsJson where gatherSteps was empty. Forgot to call any gathering method before requesting results.","solutions":["Ensure at least one step is added before calling createFlowResult() — call navigate(), startTimespan()/endTimespan(), or snapshot() at least once","Track step count in your code and guard the result call","If loading from saved artifacts, verify gatherSteps array is non-empty before calling auditGatherSteps"],"exampleFix":"// before — no steps added\nconst flow = new UserFlow(page);\nconst result = await flow.createFlowResult(); // throws\n\n// after — add at least one step\nconst flow = new UserFlow(page);\nawait flow.navigate('https://example.com');\nconst result = await flow.createFlowResult();","handlingStrategy":"validation","validationCode":"// Check that at least one step exists before requesting results\nif (flow._gatherSteps.length === 0) {\n  throw new Error('Add at least one step (navigate/timespan/snapshot) before getting results');\n}\nconst result = await flow.createFlowResult();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always add at least one step before calling createFlowResult or generateReport","Track step count in your own variable to guard conditional flows","Verify gatherSteps array is non-empty when loading saved artifacts"],"tags":["user-flow","result-generation","validation"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}