prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  `DigestEntries` returns a `Directory` instead of an empty vector for non-matching digest
  
  
  </issue>
  <code>
  [start of src/python/pants/jvm/util_rules.py]
  1 # Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
  2 # Licensed under the Apache License, Version 2.0 (see LICENSE).
  3 
  4 from __future__ import annotations
  5 
  6 from dataclasses import dataclass
  7 
  8 from pants.engine.fs import Digest, DigestEntries, DigestSubset, FileDigest, FileEntry, PathGlobs
  9 from pants.engine.rules import Get, collect_rules, rule
  10 
  11 
  12 @dataclass(frozen=True)
  13 class ExtractFileDigest:
  14     digest: Digest
  15     file_path: str
  16 
  17 
  18 @rule
  19 async def digest_to_file_digest(request: ExtractFileDigest) -> FileDigest:
  20     digest = await Get(Digest, DigestSubset(request.digest, PathGlobs([request.file_path])))
  21     files_or_directories = await Get(DigestEntries, Digest, digest)
  22     digest_entries = [entry for entry in files_or_directories if isinstance(entry, FileEntry)]
  23 
  24     if len(digest_entries) == 0:
  25         raise Exception(f"ExtractFileDigest: '{request.file_path}' not found in {request.digest}.")
  26     elif len(digest_entries) > 1:
  27         raise Exception(
  28             f"ExtractFileDigest: Unexpected error: '{request.file_path}' found multiple times in {request.digest}"
  29         )
  30 
  31     file_info = digest_entries[0]
  32     return file_info.file_digest
  33 
  34 
  35 def rules():
  36     return [*collect_rules()]
  37
  [end of src/python/pants/jvm/util_rules.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/python/pants/jvm/util_rules.py b/src/python/pants/jvm/util_rules.py
  --- a/src/python/pants/jvm/util_rules.py
  +++ b/src/python/pants/jvm/util_rules.py
  @@ -18,8 +18,7 @@
   @rule
   async def digest_to_file_digest(request: ExtractFileDigest) -> FileDigest:
       digest = await Get(Digest, DigestSubset(request.digest, PathGlobs([request.file_path])))
  -    files_or_directories = await Get(DigestEntries, Digest, digest)
  -    digest_entries = [entry for entry in files_or_directories if isinstance(entry, FileEntry)]
  +    digest_entries = await Get(DigestEntries, Digest, digest)
   
       if len(digest_entries) == 0:
           raise Exception(f"ExtractFileDigest: '{request.file_path}' not found in {request.digest}.")
  @@ -29,6 +28,12 @@
           )
   
       file_info = digest_entries[0]
  +
  +    if not isinstance(file_info, FileEntry):
  +        raise AssertionError(
  +            f"Unexpected error: '{request.file_path}' refers to a directory, not a file."
  +        )
  +
       return file_info.file_digest
  
verification_info: {"golden_diff": "diff --git a/src/python/pants/jvm/util_rules.py b/src/python/pants/jvm/util_rules.py\n--- a/src/python/pants/jvm/util_rules.py\n+++ b/src/python/pants/jvm/util_rules.py\n@@ -18,8 +18,7 @@\n @rule\n async def digest_to_file_digest(request: ExtractFileDigest) -> FileDigest:\n     digest = await Get(Digest, DigestSubset(request.digest, PathGlobs([request.file_path])))\n-    files_or_directories = await Get(DigestEntries, Digest, digest)\n-    digest_entries = [entry for entry in files_or_directories if isinstance(entry, FileEntry)]\n+    digest_entries = await Get(DigestEntries, Digest, digest)\n \n     if len(digest_entries) == 0:\n         raise Exception(f\"ExtractFileDigest: '{request.file_path}' not found in {request.digest}.\")\n@@ -29,6 +28,12 @@\n         )\n \n     file_info = digest_entries[0]\n+\n+    if not isinstance(file_info, FileEntry):\n+        raise AssertionError(\n+            f\"Unexpected error: '{request.file_path}' refers to a directory, not a file.\"\n+        )\n+\n     return file_info.file_digest\n", "issue": "`DigestEntries` returns a `Directory` instead of an empty vector for non-matching digest\n\n", "before_files": [{"content": "# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n\nfrom __future__ import annotations\n\nfrom dataclasses import dataclass\n\nfrom pants.engine.fs import Digest, DigestEntries, DigestSubset, FileDigest, FileEntry, PathGlobs\nfrom pants.engine.rules import Get, collect_rules, rule\n\n\n@dataclass(frozen=True)\nclass ExtractFileDigest:\n    digest: Digest\n    file_path: str\n\n\n@rule\nasync def digest_to_file_digest(request: ExtractFileDigest) -> FileDigest:\n    digest = await Get(Digest, DigestSubset(request.digest, PathGlobs([request.file_path])))\n    files_or_directories = await Get(DigestEntries, Digest, digest)\n    digest_entries = [entry for entry in files_or_directories if isinstance(entry, FileEntry)]\n\n    if len(digest_entries) == 0:\n        raise Exception(f\"ExtractFileDigest: '{request.file_path}' not found in {request.digest}.\")\n    elif len(digest_entries) > 1:\n        raise Exception(\n            f\"ExtractFileDigest: Unexpected error: '{request.file_path}' found multiple times in {request.digest}\"\n        )\n\n    file_info = digest_entries[0]\n    return file_info.file_digest\n\n\ndef rules():\n    return [*collect_rules()]\n", "path": "src/python/pants/jvm/util_rules.py"}]}