Skip to content

fix: return app metadata and lud16 in get_info without scope#2152

Open
im-adithya wants to merge 3 commits intomasterfrom
fix/get-info-metadata
Open

fix: return app metadata and lud16 in get_info without scope#2152
im-adithya wants to merge 3 commits intomasterfrom
fix/get-info-metadata

Conversation

@im-adithya
Copy link
Member

@im-adithya im-adithya commented Mar 18, 2026

Fixes #1997

Summary by CodeRabbit

  • Bug Fixes
    • Consistent app metadata now appears in info responses — app ID, name and additional metadata are included.
    • Lightning Address is reliably computed and returned where applicable, even in cases without certain permissions.
    • Reduced duplicate metadata behavior so info responses are more predictable.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

Centralizes app metadata deserialization and LightningAddress (lud16) computation in the get_info controller before permission checks, removing duplicate post-fetch metadata logic. Tests updated to create apps with explicit metadata and assert metadata and lud16 are present in get_info responses.

Changes

Cohort / File(s) Summary
Controller Metadata Refactoring
nip47/controllers/get_info_controller.go
Moves app metadata deserialization and defaulting (id, name) earlier in the handler, computes/attaches LightningAddress (lud16) based on app/subwallet metadata or isolation, and removes the duplicated metadata processing previously present after the info fetch.
Test Updates
nip47/controllers/get_info_controller_test.go
Replaces helper app creation with explicit AppsService.CreateApp(..., metadata) calls, renames local variables to infoResponse, and adds assertions verifying Metadata fields (a, id, name, lud16) and non-nil LightningAddress where applicable across permission scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller
    participant AppsService
    participant PermissionChecker
    participant InfoProvider

    Client->>Controller: HandleGetInfoEvent
    Controller->>AppsService: Load app (including raw Metadata)
    AppsService-->>Controller: app (with Metadata)
    Controller->>Controller: Deserialize/normalize Metadata, set id/name, compute lud16
    Controller->>PermissionChecker: Check permissions for request
    PermissionChecker-->>Controller: permission result
    Controller->>InfoProvider: Fetch node/subwallet info (if permitted)
    InfoProvider-->>Controller: info
    Controller-->>Client: get_info response (includes Metadata + lud16)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled through metadata, neat and spry,
Lud16 now shines — no longer shy,
Early I sorted each id and name,
Tests now sing the LightningAddress' name,
A tiny hop — and nulls say goodbye! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: returning app metadata and lud16 in get_info without requiring additional scope.
Linked Issues check ✅ Passed The changes centralize metadata/lud16 handling before permission checks and update tests to verify metadata and LightningAddress are returned without scope, directly addressing issue #1997's requirement.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the lud16/metadata return behavior in get_info responses, with no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/get-info-metadata

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
nip47/controllers/get_info_controller_test.go (2)

311-312: Redundant assert.NoError(t, err) check.

Same issue as in TestHandleGetInfoEvent_WithMetadataerr hasn't changed since line 272.

✂️ Proposed fix
 	assert.Contains(t, nodeInfo.Methods, "get_info")
 	assert.Equal(t, []string{}, nodeInfo.Notifications)

-	assert.NoError(t, err)
 	assert.Equal(t, float64(123), nodeInfo.Metadata.(map[string]interface{})["a"])
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nip47/controllers/get_info_controller_test.go` around lines 311 - 312, Remove
the redundant assert.NoError(t, err) at the end of
TestHandleGetInfoEvent_WithMetadata (the err value wasn't modified since the
earlier check around line 272), leaving only the assert.Equal that verifies
nodeInfo.Metadata; locate the assertion by the symbols assert.NoError and
assert.Equal(t, float64(123), nodeInfo.Metadata.(map[string]interface{})["a"])
and delete the unnecessary assert.NoError call.

252-253: Redundant assert.NoError(t, err) check.

The err variable hasn't been reassigned since the check at line 213, making this assertion unnecessary.

✂️ Proposed fix
 	assert.Contains(t, nodeInfo.Methods, "get_info")
 	assert.Equal(t, []string{}, nodeInfo.Notifications)

-	assert.NoError(t, err)
 	assert.Equal(t, float64(123), nodeInfo.Metadata.(map[string]interface{})["a"])
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nip47/controllers/get_info_controller_test.go` around lines 252 - 253, Remove
the redundant assert.NoError(t, err) call because the err variable isn't
reassigned after the earlier check, so keep the existing assertion comparing
nodeInfo.Metadata (assert.Equal(t, float64(123),
nodeInfo.Metadata.(map[string]interface{})["a"])) and delete the unnecessary
assert.NoError(t, err) to avoid duplicate checks; locate this inside the test
that sets nodeInfo and err and remove that single assertion line.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@nip47/controllers/get_info_controller_test.go`:
- Around line 311-312: Remove the redundant assert.NoError(t, err) at the end of
TestHandleGetInfoEvent_WithMetadata (the err value wasn't modified since the
earlier check around line 272), leaving only the assert.Equal that verifies
nodeInfo.Metadata; locate the assertion by the symbols assert.NoError and
assert.Equal(t, float64(123), nodeInfo.Metadata.(map[string]interface{})["a"])
and delete the unnecessary assert.NoError call.
- Around line 252-253: Remove the redundant assert.NoError(t, err) call because
the err variable isn't reassigned after the earlier check, so keep the existing
assertion comparing nodeInfo.Metadata (assert.Equal(t, float64(123),
nodeInfo.Metadata.(map[string]interface{})["a"])) and delete the unnecessary
assert.NoError(t, err) to avoid duplicate checks; locate this inside the test
that sets nodeInfo and err and remove that single assertion line.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc8f751c-baed-4dbb-b487-e1d407af167b

📥 Commits

Reviewing files that changed from the base of the PR and between 8b1504a and daa8f22.

📒 Files selected for processing (2)
  • nip47/controllers/get_info_controller.go
  • nip47/controllers/get_info_controller_test.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
nip47/controllers/get_info_controller_test.go (1)

70-85: Consider extracting a shared get_info response assertion helper.

This assertion block is repeated in multiple tests; a small helper would reduce drift and make future response-shape updates easier.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nip47/controllers/get_info_controller_test.go` around lines 70 - 85, Extract
the repeated assertions into a test helper (e.g., a function like
assertGetInfoResponse or requireGetInfoResponse) that accepts testing.T, the
publishedResponse.Result (or *getInfoResponse), the expected lightningAddress
and app values; move the checks for Alias, Color, Pubkey, Network, BlockHeight,
BlockHash being nil, the LightningAddress presence and value, Methods containing
models.GET_INFO_METHOD, empty Notifications, and Metadata entries ("a", "id",
"name") into that helper and replace the duplicated assertion block with a
single call to the helper from each test that currently repeats these
assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@nip47/controllers/get_info_controller_test.go`:
- Around line 70-85: Extract the repeated assertions into a test helper (e.g., a
function like assertGetInfoResponse or requireGetInfoResponse) that accepts
testing.T, the publishedResponse.Result (or *getInfoResponse), the expected
lightningAddress and app values; move the checks for Alias, Color, Pubkey,
Network, BlockHeight, BlockHash being nil, the LightningAddress presence and
value, Methods containing models.GET_INFO_METHOD, empty Notifications, and
Metadata entries ("a", "id", "name") into that helper and replace the duplicated
assertion block with a single call to the helper from each test that currently
repeats these assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a4b14661-efba-480d-a626-6362157379a9

📥 Commits

Reviewing files that changed from the base of the PR and between daa8f22 and d27deab.

📒 Files selected for processing (1)
  • nip47/controllers/get_info_controller_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_info response includes lud16 field but it's always null

2 participants