{"record":{"id":"c8a7c02cb66c7ef6","repo":"phacility/phabricator","slug":"unable-to-find-lines","errorCode":null,"errorMessage":"Unable to find lines.","messagePattern":"Unable to find lines\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/harbormaster/controller/HarbormasterBuildLogRenderController.php","lineNumber":188,"sourceCode":"\n      if ($data_key === null) {\n        throw new Exception(\n          pht('Unable to find fetch!'));\n      }\n\n      $anchor_key = null;\n      foreach ($reads[$data_key]['lines'] as $line_key => $line) {\n        $s = $line['offset'];\n        $e = $s + $line['length'];\n\n        if (($s <= $anchor_byte) && ($e > $anchor_byte)) {\n          $anchor_key = $line_key;\n          break;\n        }\n      }\n\n      if ($anchor_key === null) {\n        throw new Exception(\n          pht(\n            'Unable to find lines.'));\n      }\n\n      if ($view['direction'] > 0) {\n        $slice_offset = $anchor_key;\n      } else {\n        $slice_offset = max(0, $anchor_key - ($view['lines'] - 1));\n      }\n      $slice_length = $view['lines'];\n\n      $views[$view_key] += array(\n        'sliceKey' => $data_key,\n        'sliceOffset' => $slice_offset,\n        'sliceLength' => $slice_length,\n      );\n    }\n","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/controller/HarbormasterBuildLogRenderController.php#L170-L206","documentation":"Second-stage invariant in the same build-log renderer: the anchor byte was found inside a fetched data window, but none of the per-line records built from that data (each spanning [line.offset, line.offset+line.length), with an exclusive end) contains it. Unlike the fetch check, the line check uses a strictly greater end bound, so an anchor sitting exactly at the end of the data (e.g. offset == log size) or an empty/zero-line fetch matches no line even though it matched the window.","triggerScenarios":"A view whose offset equals the log's total size (nothing left to read forward), a fetch whose length was clamped to zero because fetchOffset already sits at EOF, or line-map markers whose recorded offsets run ahead of the actual chunk data (corrupted or half-archived log).","commonSituations":"Scrolling/paging to the very end of a log that has no trailing newline; requesting the tail of a log that shrank during archival; corrupted chunk tables making the computed line offsets not cover the anchor.","solutions":["Reload the log URL fresh (drop headOffset/tailOffset/lines parameters) so the view offsets are recomputed against the current log.","Verify the log's chunk data is intact (chunk table vs recorded length) if one specific log always fails.","If you maintain this code, clamp the anchor into the last line when it lands at EOF instead of throwing (treat anchor == end of data as the final line)."],"exampleFix":"// before\nif ($anchor_key === null) {\n  throw new Exception(pht('Unable to find lines.'));\n}\n\n// after\nif ($anchor_key === null) {\n  $line_data = $reads[$data_key]['lines'];\n  if ($line_data && $anchor_byte >= $log_size - 1) {\n    $anchor_key = last_key($line_data);\n  }\n}\nif ($anchor_key === null) {\n  throw new Exception(pht('Unable to find lines.'));\n}","handlingStrategy":"validation","validationCode":"// Only request line-anchored views strictly inside the data:\nif ($view['offset'] >= $log_size) {\n  $view['offset'] = max(0, $log_size - 1);\n}\n// Skip views whose clamped fetch length is zero (fetchOffset already at EOF)","typeGuard":null,"tryCatchPattern":"try {\n  $anchor_key = findAnchorLine($reads, $anchor_byte);\n} catch (Exception $e) {\n  $anchor_key = last_key($reads[$data_key]['lines']); // degrade to last line\n}","preventionTips":["Never issue a view with offset equal to the log's total size when there is no trailing newline; use size-1.","Recompute offsets after archival/compression events, which change log size and line maps.","Verify chunk integrity for logs that repeatedly fail, instead of retrying blindly."],"tags":["harbormaster","build-log","rendering","boundary-condition"],"backgroundTag":"log-line-map-mismatch","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}