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

DataBiosphere / azul / 20757414267

06 Jan 2026 06:06PM UTC coverage: 85.021% (-0.03%) from 85.047%
20757414267

Pull #7623

github

web-flow
Merge bffa85444 into 158e524c6
Pull Request #7623: Fix: Frequent timeouts from TDR (#7452)

19792 of 23279 relevant lines covered (85.02%)

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
    ServiceUnavailableError,
19
    TerraTimeoutError,
20
)
21
from azul.http import (
1✔
22
    LimitedTimeoutException,
23
    TooManyRequestsException,
24
)
25
from azul.service.source_service import (
1✔
26
    SourceService,
27
)
28
from azul.types import (
1✔
29
    JSONs,
30
)
31

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

34

35
class SourceController(AppController):
1✔
36

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

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

69
    def _list_source_ids(self,
1✔
70
                         catalog: CatalogName,
71
                         authentication: Authentication | None
72
                         ) -> set[str]:
73
        try:
1✔
74
            source_ids = self._source_service.list_source_ids(catalog, authentication)
1✔
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