• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DataBiosphere / azul / 21772456865

07 Feb 2026 02:16AM UTC coverage: 85.042% (+0.02%) from 85.02%
21772456865

Pull #7693

github

web-flow
Merge e8b472a84 into fa8d30dff
Pull Request #7693: Fix: Mirror URI in manifest /index/files response is set for MA files (#7687)

20019 of 23540 relevant lines covered (85.04%)

0.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.1
src/azul/service/source_controller.py
1
import logging
1✔
2

3
from chalice import (
1✔
4
    TooManyRequestsError,
5
    UnauthorizedError,
6
)
7

8
from azul import (
1✔
9
    CatalogName,
10
    cached_property,
11
)
12
from azul.auth import (
1✔
13
    Authentication,
14
)
15
from azul.chalice import (
1✔
16
    AppController,
17
    BadGatewayError,
18
    TerraTimeoutError,
19
)
20
from azul.http import (
1✔
21
    LimitedTimeoutException,
22
    TooManyRequestsException,
23
)
24
from azul.service.source_service import (
1✔
25
    SourceService,
26
)
27
from azul.types import (
1✔
28
    JSONs,
29
)
30

31
log = logging.getLogger(__name__)
1✔
32

33

34
class SourceController(AppController):
1✔
35

36
    @cached_property
1✔
37
    def _source_service(self) -> SourceService:
1✔
38
        return SourceService()
1✔
39

40
    def list_sources(self,
1✔
41
                     catalog: CatalogName,
42
                     authentication: Authentication | None
43
                     ) -> JSONs:
44
        try:
1✔
45
            sources = self._source_service.list_accessible_sources(catalog, authentication)
1✔
46
        except PermissionError:
×
47
            raise UnauthorizedError
×
48
        except LimitedTimeoutException as e:
×
49
            raise TerraTimeoutError(*e.args)
×
50
        except TooManyRequestsException as e:
×
51
            raise TooManyRequestsError(*e.args)
×
52
        else:
53
            authoritative_source_ids = {source.id for source in sources}
1✔
54
            cached_source_ids = self._list_source_ids(catalog, authentication)
1✔
55
            # For optimized performance, the cache may include source IDs that
56
            # are accessible but are not configured for indexing. Therefore, we
57
            # expect the set of actual sources to be a subset of the cached
58
            # sources.
59
            diff = authoritative_source_ids - cached_source_ids
1✔
60
            if diff:
1✔
61
                log.debug(diff)
×
62
                raise BadGatewayError('Inconsistent response from repository')
×
63
            return [
1✔
64
                {'sourceId': source.id, 'sourceSpec': str(source.spec)}
65
                for source in sources
66
            ]
67

68
    def _list_source_ids(self,
1✔
69
                         catalog: CatalogName,
70
                         authentication: Authentication | None
71
                         ) -> set[str]:
72
        try:
1✔
73
            source_ids = self._source_service.list_accessible_source_ids(catalog,
1✔
74
                                                                         authentication)
75
        except PermissionError:
×
76
            raise UnauthorizedError
×
77
        except LimitedTimeoutException as e:
×
78
            raise TerraTimeoutError(*e.args)
×
79
        except TooManyRequestsException as e:
×
80
            raise TooManyRequestsError(*e.args)
×
81
        else:
82
            return source_ids
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc