Skip to content

fix(pairing): store plaintext code so list_pending shows approvable value - #46630

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/pairing-code-display
Closed

fix(pairing): store plaintext code so list_pending shows approvable value#46630
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/pairing-code-display

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes hermes pairing list displaying a hash prefix instead of the actual pairing code. The displayed value could not be used with hermes pairing approve, causing "Code not found or expired" errors and eventual lockout.

Related Issue

Fixes #46580

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • gateway/pairing.py: Store plaintext code in pending entry during generate_code(); update list_pending() to return the stored code instead of hash[:8]; add backward-compatible fallback for legacy entries without a code key.
  • tests/test_pairing_code_display.py: 4 tests — code-is-approvable round-trip, code format validation, legacy-entry fallback, multi-platform correctness.

How to Test

  1. Start a Hermes instance with Telegram gateway enabled
  2. Send a message from an unrecognized Telegram user to trigger pairing
  3. Run hermes pairing list — the Code column now shows the actual code sent to the user
  4. Run hermes pairing approve telegram <displayed-code> — should succeed without lockout
  5. Verify the dashboard Approve button also works (it uses the same code field)

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Code Intelligence

  • Analyzed: gateway/pairing.pyPairingStore.generate_code(), PairingStore.list_pending(), PairingStore.approve_code()
  • Callers of list_pending(): hermes_cli/pairing.py::_cmd_list(), hermes_cli/web_server.py::list_pairing()
  • Blast radius: LOW — 1 data field added to pending entries; backward-compatible fallback for old entries
  • Related patterns: hash-stored credentials with display-side plaintext (common in pairing/OAuth flows)

…alue

list_pending() was displaying hash_val[:8] as the "code" but
approve_code() expects the original plaintext code.  Operators
copying the displayed value into ``hermes pairing approve`` got
"Code not found or expired" and eventually triggered lockout.

Store the plaintext code alongside the hash in generate_code() and
return it from list_pending().  Legacy entries without a ``code``
key gracefully fall back to hash[:8].

Fixes NousResearch#46580
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter P2 Medium — degraded but workaround exists labels Jun 15, 2026
@liuhao1024

Copy link
Copy Markdown
Contributor Author

Closing as duplicate of #46584 by @itsflownium, which implements the same fix with a more comprehensive approach (stable request ID, dashboard UI updates, full test coverage). That PR was opened earlier (2026-06-15T10:20Z) and has all CI checks passing. Our approach stored the plaintext code directly but failed to update the existing tests/gateway/test_pairing.py tests, causing 3 CI failures.

@liuhao1024 liuhao1024 closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram pairing list shows non-approvable code in CLI

2 participants