Migrate primary to labeled path, remove all flat-path fallback logic
This commit is contained in:
@@ -127,15 +127,6 @@ def list_google_accounts() -> str:
|
|||||||
accounts[label] = val.get('email', s['Name'])
|
accounts[label] = val.get('email', s['Name'])
|
||||||
except Exception:
|
except Exception:
|
||||||
accounts[label] = s['Name']
|
accounts[label] = s['Name']
|
||||||
# Also check flat path as 'primary' if not already in labeled list
|
|
||||||
if 'primary' not in accounts:
|
|
||||||
flat = f'agent-claw/google-credentials/{safe_actor_id}'
|
|
||||||
try:
|
|
||||||
import json as _json2
|
|
||||||
val = _json2.loads(sm.get_secret_value(SecretId=flat)['SecretString'])
|
|
||||||
accounts['primary'] = val.get('email', flat)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
if accounts:
|
if accounts:
|
||||||
parts = [f'{label} ({email})' for label, email in accounts.items()]
|
parts = [f'{label} ({email})' for label, email in accounts.items()]
|
||||||
return 'Connected Google accounts: ' + ', '.join(parts)
|
return 'Connected Google accounts: ' + ', '.join(parts)
|
||||||
|
|||||||
@@ -98,14 +98,8 @@ def _load_all_creds(actor_id: str) -> dict[str, Credentials]:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'[google] list_secrets failed: {e}')
|
print(f'[google] list_secrets failed: {e}')
|
||||||
|
|
||||||
# Always include flat secret as 'primary' if not already in result
|
# Note: all accounts now stored at agent-claw/google-credentials/{actor_id}/{label}
|
||||||
if 'primary' not in result:
|
# flat path (no label) is legacy and no longer needed
|
||||||
flat = f'agent-claw/google-credentials/{safe}'
|
|
||||||
try:
|
|
||||||
result['primary'] = _load_creds_from_secret(flat)
|
|
||||||
print(f'[google] loaded creds from flat path actor={actor_id}')
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
_creds_cache[actor_id] = (now, result)
|
_creds_cache[actor_id] = (now, result)
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user