Closes #65
Environment
FindTheMag 3.5 (reports as 3.3 in log — known version string bug)
Gridcoin wallet: v5.5.0.0 on Windows 11
Python 3.11.9
Symptom
FTM fails to fetch mag ratios from both the wallet and the gridcoinstats web fallback at startup, logs 'NoneType' object has no attribute 'upper', and falls back to zero mag ratios for all projects. BOINC control still works, but project weighting is blind.
Root cause
get_project_mag_ratios_from_response() iterates contract_contents.projects from the superblocks response and calls grc_project_name_to_url() for each project name. When that function can't match a project name (e.g., a project present in a superblock but absent from listprojects — which can happen across wallet versions or during greylisting transitions), it returns None. That None is passed directly to resolve_url_database(), which calls url.upper() unconditionally on line 155, producing the crash.
The same crash hits the gridcoinstats web fallback because it routes through the same get_project_mag_ratios_from_response() parser.
Confirmed via
Tracing response["result"] from superblocks [7, true] through get_project_mag_ratios_from_response() → grc_project_name_to_url() → resolve_url_database(). Wallet RPC connectivity is fine; the crash is purely in the parser.
Fix
Add a None guard before the resolve_url_database() call in get_project_mag_ratios_from_response():
python# Before (crashes when grc_project_name_to_url returns None):
project_url = grc_project_name_to_url(project_name, project_resolver_dict)
canonical_url = resolve_url_database(project_url)
return_dict[canonical_url] = mag_per_project / average_rac
After:
project_url = grc_project_name_to_url(project_name, project_resolver_dict)
if project_url is None:
log.debug("Could not resolve URL for project '{}', skipping mag ratio".format(project_name))
continue
canonical_url = resolve_url_database(project_url)
return_dict[canonical_url] = mag_per_project / average_rac
This is reproducible on any setup running wallet 5.5.0 where a superblock contains a project name that doesn't cleanly resolve via listprojects.
Closes #65
Environment
FindTheMag 3.5 (reports as 3.3 in log — known version string bug)
Gridcoin wallet: v5.5.0.0 on Windows 11
Python 3.11.9
Symptom
FTM fails to fetch mag ratios from both the wallet and the gridcoinstats web fallback at startup, logs 'NoneType' object has no attribute 'upper', and falls back to zero mag ratios for all projects. BOINC control still works, but project weighting is blind.
Root cause
get_project_mag_ratios_from_response() iterates contract_contents.projects from the superblocks response and calls grc_project_name_to_url() for each project name. When that function can't match a project name (e.g., a project present in a superblock but absent from listprojects — which can happen across wallet versions or during greylisting transitions), it returns None. That None is passed directly to resolve_url_database(), which calls url.upper() unconditionally on line 155, producing the crash.
The same crash hits the gridcoinstats web fallback because it routes through the same get_project_mag_ratios_from_response() parser.
Confirmed via
Tracing response["result"] from superblocks [7, true] through get_project_mag_ratios_from_response() → grc_project_name_to_url() → resolve_url_database(). Wallet RPC connectivity is fine; the crash is purely in the parser.
Fix
Add a None guard before the resolve_url_database() call in get_project_mag_ratios_from_response():
python# Before (crashes when grc_project_name_to_url returns None):
project_url = grc_project_name_to_url(project_name, project_resolver_dict)
canonical_url = resolve_url_database(project_url)
return_dict[canonical_url] = mag_per_project / average_rac
After:
project_url = grc_project_name_to_url(project_name, project_resolver_dict)
if project_url is None:
log.debug("Could not resolve URL for project '{}', skipping mag ratio".format(project_name))
continue
canonical_url = resolve_url_database(project_url)
return_dict[canonical_url] = mag_per_project / average_rac
This is reproducible on any setup running wallet 5.5.0 where a superblock contains a project name that doesn't cleanly resolve via listprojects.