goharbor/harbor · error
bad redis url for registry:%s
Error message
bad redis url for registry:%s
What it means
Thrown by parse_redis() in make/photon/prepare/utils/registry.py when the registry redis URL's scheme is not one of redis, rediss, redis+sentinel, rediss+sentinel. The function maps the URL into registry config keys (host, password, db index, TLS flag, sentinel master set); an unknown scheme means it cannot interpret the URL at all. Normally redis_url_reg is generated by get_redis_configs() from harbor.yml's redis/external_redis sections (scheme derived from sentinel_master_set and tlsOptions), so this raise points at a malformed or externally injected URL string.
Source
Thrown at make/photon/prepare/utils/registry.py:89
return {
'sentinel_master_set': u.path.split('/')[1],
'redis_host': u.netloc.split('@')[-1],
'redis_password': '' if u.password is None else unquote(u.password),
'redis_username': '' if u.username is None else unquote(u.username),
'redis_db_index_reg': len(u.path.split('/')) == 3 and int(u.path.split('/')[2]) or 0,
'redis_enableTLS': 'false',
}
elif u.scheme == 'rediss+sentinel':
return {
'sentinel_master_set': u.path.split('/')[1],
'redis_host': u.netloc.split('@')[-1],
'redis_password': '' if u.password is None else unquote(u.password),
'redis_username': '' if u.username is None else unquote(u.username),
'redis_db_index_reg': len(u.path.split('/')) == 3 and int(u.path.split('/')[2]) or 0,
'redis_enableTLS': 'true',
}
else:
raise Exception('bad redis url for registry:' + redis_url)
def get_storage_provider_info(provider_name, provider_config):
provider_config_copy = copy.deepcopy(provider_config)
if provider_name == "filesystem":
if not (provider_config_copy and ('rootdirectory' in provider_config_copy)):
provider_config_copy['rootdirectory'] = '/storage'
if provider_name == 'gcs' and provider_config_copy.get('keyfile'):
provider_config_copy['keyfile'] = '/etc/registry/gcs.key'
# generate storage configuration section in yaml format
storage_provider_conf_list = [provider_name + ':']
for config in provider_config_copy.items():
if config[1] is None:
value = ''
elif config[1] == True:
value = 'true'
else:
value = config[1]
storage_provider_conf_list.append('{}: {}'.format(config[0], value))View on GitHub (pinned to 7b2fd08cc5)
Solutions
- Use exactly one of the four schemes: redis:// (plain), rediss:// (TLS), redis+sentinel:// (sentinel), rediss+sentinel:// (sentinel+TLS)
- Prefer generating the URL with utils.configs.get_redis_url()/get_redis_configs() so the scheme is derived correctly from harbor.yml
- Strip whitespace: redis_url = redis_url.strip() before passing it in
- For sentinel URLs include the master name in the path: redis+sentinel://user:pass@host1:26379,host2:26379/mymaster/1
- Re-run prepare
Example fix
# hand-built dict (before)
cfg['redis_url_reg'] = 'redis-sentinel://sentinel1:26379/mymaster/1'
# after
from utils.configs import get_redis_configs
cfg.update(get_redis_configs(external_redis={
'host': 'sentinel1:26379,sentinel2:26379',
'sentinel_master_set': 'mymaster',
'registry_db_index': 1,
'password': 'pass'})) # yields redis+sentinel://... Defensive patterns
Strategy: validation
Validate before calling
from urllib.parse import urlsplit
ALLOWED = {'redis', 'rediss', 'redis+sentinel', 'rediss+sentinel'}
u = urlsplit(redis_url.strip())
if u.scheme not in ALLOWED:
raise SystemExit('bad redis url scheme %r; allowed: %s' % (u.scheme, sorted(ALLOWED))) Prevention
- Let Harbor build redis URLs from harbor.yml instead of hand-writing them
- Remember TLS is 'rediss', sentinel is '+sentinel' - no hyphens
- Trim YAML/template values that flow into connection URLs
When it happens
Trigger: prepare_registry(config_dict) is called with config_dict['redis_url_reg'] that urlsplit cannot parse into a known scheme: leading/trailing whitespace (' redis://...' yields an empty/odd scheme), a typo like 'redissentinel://' or 'redis-sentinel://', or a completely missing '//' separator. Happens with custom tooling that builds the URL by hand instead of using configs.get_redis_configs().
Common situations: Scripts that wrap prepare and hand-assemble redis URLs; copy-paste from Redis/Sentinel docs that use different scheme spellings; YAML values with stray spaces after templating; older configs using 'redis+sentinel' variants with wrong separators.
Related errors
- invalid redis URL
- namespace of redis worker is required
- Please specify hostname
- Error: The protocol is https but attribute ssl_cert is not s
- Error: The protocol is https but attribute ssl_cert_key is n
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/80c9a57507e91bbf.
Report an issue: GitHub.