Skip to content

Filter notes by tag with the TagTitle key - #140

Closed
Ketan-K17 wants to merge 1 commit into
jonhadfield:mainfrom
Ketan-K17:fix-get-notes-tag-filter
Closed

Ketan-K17 wants to merge 1 commit into
jonhadfield:mainfrom
Ketan-K17:fix-get-notes-tag-filter

Conversation

@Ketan-K17

Copy link
Copy Markdown
Contributor

Fixes #135. Depends on jonhadfield/gosn-v2#108: it needs a gosn-v2 release with that fix and a dependency bump here.

Summary

get notes, get trash and search filtered by tag with a key gosn-v2 doesn't handle, so the filter matched every note.

 items.Filter{
 	Type:       common.SNItemTypeNote,
-	Key:        common.SNItemTypeTag, // "Tag": falls through to default, matches all
-	Comparison: "contains",           // TagTitle has no "contains"
+	Key:        "TagTitle",
+	Comparison: "==",
 	Value:      t,
 }

Evidence

sn get notes --tag sn-cli-pr-test on an account where that tag holds 2 notes:

  • Before: 45 notes (every note in the account).
    After (this branch + gosn-v2#108 via a local replace): the 2 notes in the tag.
  • This branch alone, on the currently pinned gosn-v2: no matches, because of the tag-order bug fixed in gosn-v2#108. That's why this PR shouldn't merge before the bump.

Merge Danger

Door: two-way

Blast Radius: tag filtering

--tag on get notes, get trash and search now actually filters. Several --tag values must all match (MatchAny is false). Tag titles are now matched exactly rather than by substring, which is what contains suggested but never did.

get notes, get trash and search filtered by tag with the key "Tag",
which gosn-v2 does not handle, so the filter matched every note. Use
"TagTitle", and "==" since TagTitle does not support "contains".

Fixes jonhadfield#135
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jonhadfield

Copy link
Copy Markdown
Owner

Landed on main as 27fa3e7, with gosn-v2 bumped to include jonhadfield/gosn-v2#108.

@jonhadfield jonhadfield closed this Nov 2, 2026
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 notes --tag returns every note

2 participants