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

snarfed / bridgy-fed / 878ced7f-3b32-4aaf-9280-63d2666620db

17 Oct 2025 03:56AM UTC coverage: 92.855% (-0.002%) from 92.857%
878ced7f-3b32-4aaf-9280-63d2666620db

push

circleci

snarfed
fix integration test test_nostr_follow_activitypub_bot_user_invalid_nip05

5939 of 6396 relevant lines covered (92.85%)

0.93 hits per line

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

58.14
/config.py
1
"""Flask config and env vars.
2

3
https://flask.palletsprojects.com/en/latest/config/
4
"""
5
import logging
1✔
6
import os
1✔
7
import re
1✔
8
import traceback
1✔
9

10
from oauth_dropins.webutil import appengine_config, appengine_info, util
1✔
11

12
# This is primarily for flashed messages, since we don't use session data
13
# otherwise.
14
SESSION_COOKIE_SECURE = True
1✔
15
SESSION_COOKIE_HTTPONLY = True
1✔
16
# Not strict because we flash messages after cross-site redirects for OAuth,
17
# which strict blocks.
18
SESSION_COOKIE_SAMESITE = 'Lax'
1✔
19
CACHE_THRESHOLD = 3000
1✔
20
# 10MiB. default is 500KiB, and we hit that on receive tasks for some web posts
21
# https://github.com/snarfed/bridgy-fed/issues/1593
22
MAX_FORM_MEMORY_SIZE = 10000000
1✔
23

24
# flask-sock, simple_websocket
25
# https://flask-sock.readthedocs.io/en/latest/quickstart.html#configuration
26
# https://simple-websocket.readthedocs.io/en/latest/api.html#the-server-class
27
SOCK_SERVER_OPTIONS = {
1✔
28
    'ping_interval': 25,
29
}
30

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

33
logging.getLogger('granary.nostr').setLevel(logging.DEBUG)
1✔
34
logging.getLogger('nostr').setLevel(logging.DEBUG)
1✔
35
logging.getLogger('nostr_hub').setLevel(logging.DEBUG)
1✔
36

37
if appengine_info.DEBUG:
1✔
38
    ENV = 'development'
1✔
39
    CACHE_TYPE = 'NullCache'
1✔
40
    SECRET_KEY = 'sooper seekret'
1✔
41

42
else:
43
    ENV = 'production'
×
44
    CACHE_TYPE = 'SimpleCache'
×
45
    SECRET_KEY = util.read('flask_secret_key')
×
46

47
    logging.getLogger().setLevel(logging.INFO)
×
48
    if logging_client := getattr(appengine_config, 'logging_client'):
×
49
        logging_client.setup_logging(log_level=logging.INFO)
×
50

51
    for logger in (
×
52
            'atproto_firehose',
53
            # 'arroba.firehose',
54
            'lexrpc',
55
            'oauth_dropins.webutil.webmention',
56
    ):
57
        logging.getLogger(logger).setLevel(logging.DEBUG)
×
58

59
    logging.getLogger('lexrpc.flask_server').setLevel(logging.INFO)
×
60
    logging.getLogger('lexrpc.server').setLevel(logging.INFO)
×
61

62

63
# for debugging ndb. also needs NDB_DEBUG env var, set in *.yaml.
64
# https://github.com/googleapis/python-ndb/blob/c55ec62b5153787404488b046c4bf6ffa02fee64/google/cloud/ndb/utils.py#L78-L81
65
# logging.getLogger('google.cloud').propagate = True
66
# logging.getLogger('google.cloud.ndb').setLevel(logging.DEBUG)
67
# logging.getLogger('google.cloud.ndb._cache').setLevel(logging.DEBUG)
68
# logging.getLogger('google.cloud.ndb.global_cache').setLevel(logging.DEBUG)
69

70
KEYS_ID_RE = re.compile(f'name: "([^"]+)"')
1✔
71

72
def only_lookups(record):
1✔
73
    msg = record.getMessage()
×
74
    if '\nkeys {' in msg:
×
75
        if id := KEYS_ID_RE.search(msg):
×
76
            stack = [frame for frame in traceback.extract_stack()[:-1]
×
77
                     if (frame.filename.startswith('/workspace/')
78
                         or 'arroba' in frame.filename)
79
                        or (frame.filename.startswith('/Users/ryan/src/')
80
                            and '/lib/' not in frame.filename)]
81
            new_msg = id.group(1) + '\n' + ''.join(traceback.format_list(stack))
×
82
            config_logger.info(new_msg)
×
83

84
            # ideally I'd return a new log record here and let the
85
            # _datastore_api logger emit it, or just modify the record passed in
86
            # here and return True, but that makes tests try to talk to google
87
            # cloud's production logging (?)
88
            #
89
            # return logging.LogRecord(record.name, record.level, record.pathname,
90
            #                       record.lineno, new_msg, record.args,
91
            #                       record.exc_info))
92

93
    return False
×
94

95
# api_logger = logging.getLogger('google.cloud.ndb._datastore_api')
96
# api_logger.setLevel(logging.DEBUG)
97
# api_logger.addFilter(only_lookups)
98

99
os.environ.setdefault('APPVIEW_HOST', 'api.bsky.local')
1✔
100
os.environ.setdefault('BGS_HOST', 'bgs.bsky.local')
1✔
101
os.environ.setdefault('PLC_HOST', 'plc.bsky.local')
1✔
102

103
if repo_token := util.read('repo_token'):
1✔
104
    os.environ.setdefault('REPO_TOKEN', repo_token)
×
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