Skip to content

feat(search): drop description from human output and e2e expectations - #50

Merged
IlyaGusev merged 5 commits into
mainfrom
feat/remove-description-field
Jul 17, 2026
Merged

feat(search): drop description from human output and e2e expectations#50
IlyaGusev merged 5 commits into
mainfrom
feat/remove-description-field

Conversation

@IlyaGusev

@IlyaGusev IlyaGusev commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Companion to keenableai/keenable-backend-ts#260, which removes the description field from /v1/search and /v1/fetch responses and makes snippet fall back to the page description server-side.

The CLI now guarantees description is never output as a separate field, regardless of backend version:

  • Search responses are normalized after every request: a legacy server's description is folded into snippet when no snippet exists, then the field is dropped. Fetch responses drop description outright. Covers both YAML (stdout) and pretty output.
  • kn search -p human output prints snippet (whitespace-flattened, truncated to 200 chars) instead of the removed description.
  • e2e: description removed from required result fields and the semantic text blob; search and fetch tests now assert the field is absent.

Verified against the live API (pre-deploy backend, still returning description): YAML output contains no description field. Safe to merge independently of the backend PR.

🤖 Generated with Claude Code

The API no longer returns a description field on search results;
snippet remains the text preview.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Remove description from search CLI pretty output and e2e assertions

✨ Enhancement 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Stop printing description in kn search -p human output to match updated API payloads.
• Update e2e search schema checks to no longer require description in results.
• Remove description from semantic relevance “blob” text used by top-k assertions.
Diagram

graph TD
  A["kn CLI"] --> B["search.rs"] --> C{{"Search API"}} --> D["results JSON"]
  D --> E["Pretty output (-p)"]
  D --> F["YAML output"]
  D --> G["e2e tests"]
  subgraph Legend
    direction LR
    _cli["CLI"] ~~~ _file["Source file"] ~~~ _api{{"External API"}} ~~~ _test["Test suite"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep printing `description` only when present (backward-compatible)
  • ➕ Preserves richer human output when pointed at older backends still returning description.
  • ➕ Avoids surprising users who relied on the description line during rollout.
  • ➖ Human output becomes dependent on backend version, making output less consistent.
  • ➖ Still carries a legacy field forward in the UI even after the contract change.
2. Replace `description` line with `snippet` preview in pretty output
  • ➕ Maintains a one-line textual preview for humans without depending on a removed field.
  • ➕ Aligns with the API field that remains the canonical preview text.
  • ➖ Changes semantics/length of the pretty output and could be noisier.
  • ➖ May require truncation/format decisions (wrapping, escaping) and could prompt new golden expectations.

Recommendation: Current approach is appropriate if the goal is strict alignment with the updated backend contract and stable output formatting. If maintaining a preview line in -p mode is important for UX, consider switching the pretty-output line to a truncated snippet (rather than reintroducing conditional legacy description).

Files changed (3) +2 / -7

Enhancement (1) +0 / -5
search.rsRemove 'description' line from 'kn search -p' pretty output +0/-5

Remove 'description' line from 'kn search -p' pretty output

• Stops reading 'description' from search results and removes the truncated description line from human-readable output. Search output now includes title, URL, and optional date metadata only.

src/commands/search.rs

Tests (2) +2 / -2
test_search.pyDrop 'description' from required search result fields +1/-1

Drop 'description' from required search result fields

• Updates the e2e schema expectations so search results are only required to include 'url', 'title', 'snippet', and 'acquired_at' (with 'published_at' still optional). Prevents false failures once the backend stops returning 'description'.

tests/e2e/test_search.py

test_semantic.pyRemove 'description' from semantic relevance text blob +1/-1

Remove 'description' from semantic relevance text blob

• Adjusts the semantic test helper to build its searchable text blob from 'title' and 'snippet' only. Keeps top-k relevance assertions aligned with the updated result payload.

tests/e2e/test_semantic.py

@qodo-code-review

qodo-code-review Bot commented Jul 17, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. No description absence assert ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
The e2e suite stops asserting anything about the description key (neither required nor forbidden),
so the API can accidentally keep returning it or reintroduce it later without tests catching the
contract regression.
Code

tests/e2e/test_search.py[10]

+RESULT_FIELDS = ("url", "title", "snippet", "acquired_at")
Evidence
test_basic_search only asserts that each field in RESULT_FIELDS exists in each result; after
this PR, description is removed from that list and no other test asserts description must be
absent. Additionally, blob() no longer reads description, further reducing coverage of that
field across the semantic suite.

tests/e2e/test_search.py[9-23]
tests/e2e/test_semantic.py[20-22]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The e2e tests currently only assert presence of a small set of required fields; after removing `description` from that list, there is no longer any assertion that `description` is *absent*. This weakens contract enforcement for the intended API change.

## Issue Context
`test_basic_search` iterates `RESULT_FIELDS` and checks `field in r`, which does not fail when extra keys exist. If the backend continues returning `description` (or later regresses), the suite will not detect it.

## Fix Focus Areas
- tests/e2e/test_search.py[9-23]

## Suggested fix
Add an explicit negative assertion inside the results loop, e.g. `assert "description" not in r`, optionally with a clear failure message. If you still need temporary compatibility with older backends, gate this assertion behind an env var or a backend-version check (if available).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread tests/e2e/test_search.py
IlyaGusev and others added 4 commits July 17, 2026 16:57
The API's snippet now falls back to the page description server-side.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Fold a legacy server's description into snippet (search) and drop it
from fetch responses, so YAML and pretty output never carry the field
regardless of backend version. e2e asserts absence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@IlyaGusev
IlyaGusev merged commit aba4dd4 into main Jul 17, 2026
12 checks passed
@IlyaGusev
IlyaGusev deleted the feat/remove-description-field branch July 17, 2026 20:30
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.

1 participant