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

DataBiosphere / azul / 24868936000

24 Apr 2026 02:21AM UTC coverage: 85.122% (+0.003%) from 85.119%
24868936000

Pull #7953

github

web-flow
Merge 60a8c4097 into 16ee28355
Pull Request #7953: Expose mirror configuration via service (#7952)

20008 of 23505 relevant lines covered (85.12%)

0.85 hits per line

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

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

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

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

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

35

36
class SourceController(Controller):
1✔
37

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

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

74
    def _list_source_ids(self,
1✔
75
                         catalog: CatalogName,
76
                         authentication: Authentication | None
77
                         ) -> set[str]:
78
        try:
1✔
79
            source_ids = self._source_service.list_source_ids(catalog, authentication)
1✔
80
        except PermissionError:
×
81
            raise UnauthorizedError
×
82
        except LimitedTimeoutException as e:
×
83
            raise TemporaryRedirectError(*e.args)
×
84
        except TooManyRequestsException as e:
×
85
            raise TooManyRequestsError(*e.args)
×
86
        else:
87
            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