Skip to content

v0.9.0 compliance: full upgrade against core/go reference#3

Open
Snider wants to merge 1 commit intomainfrom
dev
Open

v0.9.0 compliance: full upgrade against core/go reference#3
Snider wants to merge 1 commit intomainfrom
dev

Conversation

@Snider
Copy link
Copy Markdown
Contributor

@Snider Snider commented Apr 28, 2026

Brings this repo to verdict: COMPLIANT against the v0.9.0 audit.

🤖 Generated with Claude Code + Codex
Co-Authored-By: Codex noreply@openai.com
Co-Authored-By: Virgil virgil@lethean.io

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved error handling in API endpoints for JSON encoding failures.
    • Enhanced error messages in help catalogue operations.
  • Tests

    • Added comprehensive test coverage for the help system, including rendering, parsing, and search functionality.
    • Migrated test suite to improved assertion framework for better clarity and maintainability.
  • Refactor

    • Simplified HTML rendering pipeline for improved performance.

bash /tmp/v090/audit.sh . → verdict: COMPLIANT (all 7 dimensions zero).

Co-authored-by: Codex <noreply@openai.com>
Co-Authored-By: Virgil <virgil@lethean.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

The PR consolidates Go dependencies by replacing explicit dappco.re/go/core/* modules with an umbrella dappco.re/go v0.9.0 package and removes testify. Test suites across pkg/help/ are systematically migrated to dappco.re/go testing helpers. HTML rendering in layout.go transitions from gohtml node-based templating to pure string composition. Error handling improves in JSON API responses and error reporting.

Changes

Cohort / File(s) Summary
Dependency Consolidation
go.mod
Replaces explicit dappco.re/go/core/* and github.com/stretchr/testify dependencies with umbrella dappco.re/go v0.9.0; adds local replace directive for development.
HTML Rendering Refactoring
pkg/help/layout.go
Removes gohtml node-based templating; replaces with pure string HTML composition in all page renderers. Converts helper functions to return HTML strings instead of node objects.
Error Handling Improvements
pkg/help/catalog.go, pkg/help/server.go
Switches structured logging (log.E) to fmt.Errorf with wrapped errors in catalog operations; adds error handling for JSON encoder failures in API handlers.
Testing Framework Migration
pkg/help/catalog_test.go, pkg/help/generate_test.go, pkg/help/ingest_test.go, pkg/help/integration_test.go, pkg/help/layout_test.go, pkg/help/parser_test.go, pkg/help/render_test.go, pkg/help/search_bench_test.go, pkg/help/search_test.go, pkg/help/server_test.go, pkg/help/stemmer_test.go, pkg/help/templates_test.go
Migrates all test suites from testify to dappco.re/go assertion utilities; updates function signatures from *testing.T/*testing.B to *T/*B and rewrites all assertion calls to corresponding helpers.
New Comprehensive Test Suite
pkg/help/ax7_test.go
Introduces 635 lines of test coverage for AX7 help/catalog system; validates Markdown rendering, site generation, HTTP routing, parsing pipelines, catalog CRUD operations, search indexing, and template rendering with HTML escaping verification.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.24% 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 'v0.9.0 compliance: full upgrade against core/go reference' directly aligns with the primary objective of this PR, which is to bring the repository into compliance with v0.9.0 audit requirements through a comprehensive upgrade.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

level=error msg="[linters_context] typechecking error: dappco.re/go@v0.9.0: replacement directory ../go does not exist"


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

Copy link
Copy Markdown

@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.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (8)
pkg/help/server.go (1)

1-1: ⚠️ Potential issue | 🟡 Minor

Typo in SPDX header: "Licence" should be "License".

The SPDX identifier uses American English spelling "License", not "Licence".

Proposed fix
-// SPDX-Licence-Identifier: EUPL-1.2
+// SPDX-License-Identifier: EUPL-1.2
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/help/server.go` at line 1, Update the SPDX header string at the top of
the file by correcting the typo "Licence" to the standard SPDX identifier
spelling "License" so the header reads "SPDX-License-Identifier: EUPL-1.2";
locate and edit the existing header comment in pkg/help/server.go (the
top-of-file SPDX comment) to perform this single-word fix.
pkg/help/templates_test.go (1)

1-1: ⚠️ Potential issue | 🟡 Minor

Typo in SPDX header.

Same "Licence" vs "License" typo.

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

In `@pkg/help/templates_test.go` at line 1, Fix the SPDX header typo by changing
the token "SPDX-Licence-Identifier: EUPL-1.2" to the correct
"SPDX-License-Identifier: EUPL-1.2" so the SPDX identifier uses "License"
(update the string that currently reads "SPDX-Licence-Identifier" in the file).
pkg/help/layout.go (2)

413-414: ⚠️ Potential issue | 🟠 Major

Snippet not escaped in search results.

On line 414, r.Snippet is inserted directly into HTML without escaping. If the snippet contains user-provided content or markdown-derived text with HTML entities, this could lead to rendering issues or XSS if the search index ever indexes untrusted content.

content.WriteString(fmt.Sprintf(`<p>%s</p>`, r.Snippet))
Proposed fix
 			if r.Snippet != "" {
-				content.WriteString(fmt.Sprintf(`<p>%s</p>`, r.Snippet))
+				content.WriteString(fmt.Sprintf(`<p>%s</p>`, html.EscapeString(r.Snippet)))
 			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/help/layout.go` around lines 413 - 414, The snippet r.Snippet is written
directly into HTML via content.WriteString(fmt.Sprintf(`<p>%s</p>`, r.Snippet))
which can lead to XSS or broken rendering; fix by HTML-escaping the snippet
before insertion (e.g., use html.EscapeString on r.Snippet or render with
text/template/htmlescape utilities) and then write the escaped value into
content (update the code around content.WriteString and the use of r.Snippet
accordingly so the output is safe).

1-1: ⚠️ Potential issue | 🟡 Minor

Typo in SPDX header: "Licence" should be "License".

Same issue as in server.go.

Proposed fix
-// SPDX-Licence-Identifier: EUPL-1.2
+// SPDX-License-Identifier: EUPL-1.2
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/help/layout.go` at line 1, The SPDX header at the top of
pkg/help/layout.go currently reads "SPDX-Licence-Identifier: EUPL-1.2" (typo
"Licence"); update that top-of-file header string to "SPDX-License-Identifier:
EUPL-1.2" and make the identical fix in server.go where the same header appears
so both files use the correct SPDX-License-Identifier spelling.
pkg/help/ingest_test.go (1)

1-1: ⚠️ Potential issue | 🟡 Minor

Typo in SPDX header.

Same "Licence" vs "License" typo.

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

In `@pkg/help/ingest_test.go` at line 1, The SPDX header contains a typo
"SPDX-Licence-Identifier" — update it to the correct token
"SPDX-License-Identifier" in pkg/help/ingest_test.go (the file-level header
string) so the SPDX header reads "SPDX-License-Identifier: EUPL-1.2".
pkg/help/search_test.go (1)

1-1: ⚠️ Potential issue | 🟡 Minor

Typo in SPDX header.

Same "Licence" vs "License" typo present.

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

In `@pkg/help/search_test.go` at line 1, Update the SPDX header string
"SPDX-Licence-Identifier: EUPL-1.2" to the correct spelling
"SPDX-License-Identifier: EUPL-1.2" (replace "Licence" with "License") so the
SPDX identifier is valid across the repository; ensure the same correction is
applied wherever the exact token "SPDX-Licence-Identifier: EUPL-1.2" appears.
pkg/help/parser_test.go (1)

1-1: ⚠️ Potential issue | 🟡 Minor

Typo in SPDX header.

Same "Licence" vs "License" typo.

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

In `@pkg/help/parser_test.go` at line 1, The SPDX header string
"SPDX-Licence-Identifier: EUPL-1.2" contains a typo ("Licence"); replace it with
the correct identifier "SPDX-License-Identifier: EUPL-1.2" wherever it appears
(e.g., at the top of parser_test.go) so the SPDX tag is valid and parsers/tools
recognize the license.
go.mod (1)

1-1: ⚠️ Potential issue | 🟠 Major

Module name does not match coding guidelines.

The Go module name must be forge.lthn.ai/core/docs as specified in the coding guidelines, but is currently set to dappco.re/go/core/docs.

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

In `@go.mod` at line 1, The module declaration in go.mod is incorrect; open go.mod
and replace the module path string "dappco.re/go/core/docs" with the required
module name "forge.lthn.ai/core/docs" so the module directive (the module line
at the top of go.mod) matches the coding guidelines and the rest of the project.
🧹 Nitpick comments (3)
pkg/help/parser_test.go (2)

641-646: Redundant assertions checking the same condition.

Lines 643-645 all verify that sections is empty using three different assertions. One assertion is sufficient.

Proposed simplification
 func TestExtractSections_Bad_EmptyString(t *T) {
 	sections := ExtractSections("")
 	AssertEmpty(t, sections)
-	AssertLen(t, sections, 0)
-	AssertFalse(t, len(sections) > 0)
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/help/parser_test.go` around lines 641 - 646, The test
TestExtractSections_Bad_EmptyString redundantly asserts the same emptiness
condition three times; simplify by keeping a single clear assertion (e.g.,
AssertEmpty) and removing the duplicate AssertLen and AssertFalse checks. Update
the test body for TestExtractSections_Bad_EmptyString to call
ExtractSections("") once and assert emptiness via AssertEmpty(t, sections) (or a
single AssertLen(t, sections, 0)) and remove AssertLen and AssertFalse to avoid
duplicated checks.

675-680: Similar redundant assertions.

AssertEqual(t, "", result) and AssertEmpty(t, result) and AssertNotContains(t, result, "-") are checking overlapping conditions. An empty string cannot contain "-".

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

In `@pkg/help/parser_test.go` around lines 675 - 680, In
TestGenerateID_Ugly_EmptyString, remove the redundant assertions so the test
only asserts emptiness: drop AssertEqual(t, "", result) and AssertNotContains(t,
result, "-") and keep a single AssertEmpty(t, result) (references:
TestGenerateID_Ugly_EmptyString, AssertEqual, AssertEmpty, AssertNotContains).
pkg/help/ax7_test.go (1)

39-636: Please avoid a second omnibus suite for behaviour already covered elsewhere.

This file overlaps catalog_test.go, generate_test.go, layout_test.go, render_test.go, and server_test.go almost one-for-one. Keeping both layers will double the maintenance burden and make failures harder to localise; I’d fold the extra edge cases into the existing focused test files instead of carrying a parallel AX7 suite.

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

In `@pkg/help/ax7_test.go` around lines 39 - 636, This AX7 omnibus test suite
duplicates tests already present in catalog_test.go, generate_test.go,
layout_test.go, render_test.go, and server_test.go; remove this redundant file
(or prune it) and move any unique edge-case tests into the focused test files
that cover the relevant area: e.g. move Topic/Index/Search edge cases to
catalog_test.go (tests referencing Catalog, newSearchIndex, Tokens, Search,
Add), move generation/output edge cases to generate_test.go (tests referencing
Generate, RenderIndexPage, RenderTopicPage, RenderSearchPage, Render404Page,
RenderMarkdown), and move HTTP/server edge cases to server_test.go (tests
referencing NewServer, Server.ListenAndServe, ServeHTTP); ensure each moved test
keeps its assertions and uses the existing helper funcs (ax7Catalog, ax7Topic)
so there is no behavioral duplication across test files.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/help/ax7_test.go`:
- Around line 1-10: This new test file in package help is missing the required
SPDX EUPL-1.2 header; add the standard SPDX header comment block (EUPL-1.2
license identifier and any required copyright line) at the very top of
ax7_test.go immediately before the "package help" declaration so the file
complies with the pkg/**/*.go SPDX header guideline.

In `@pkg/help/catalog.go`:
- Around line 1-2: Add the required SPDX license header for EUPL-1.2 at the top
of the source file so the package declaration (package help) is preceded by the
SPDX comment block; update the header to match the project's standard SPDX
format for pkg/**/*.go files and ensure it is placed before any package or
import statements to satisfy licensing checks.

In `@pkg/help/server_test.go`:
- Around line 4-9: The tests in pkg/help/server_test.go (and the other migrated
files) use a dot-import of dappco.re/go instead of the repo-standard testify;
revert the import to use "github.com/stretchr/testify/assert" and
"github.com/stretchr/testify/require" (remove . "dappco.re/go"), then update
assertion calls in functions like those in server_test.go to call assert.* and
require.* as appropriate; apply the same replacement across the other 12
migrated test files to restore consistent use of testify.

In `@pkg/help/server.go`:
- Around line 135-141: Replace the current double-write status flow when query
== "" so you don't call http.Error after already calling WriteHeader: either (A)
use http.Error to send the 400 with a plain text message (e.g. http.Error(w,
"missing query parameter 'q'", http.StatusBadRequest)) and remove
WriteHeader/Encode, or (B) keep the JSON response path but do not call
WriteHeader before a potential fallback http.Error — instead set the status only
when you know encoding succeeded and on encode failure log the error and write a
500 (e.g. call w.WriteHeader(http.StatusInternalServerError) before writing the
error body). Update the branch that uses json.NewEncoder(w).Encode(...)
accordingly so a second http.Error is never invoked after WriteHeader.
- Around line 117-122: The current handler calls
w.WriteHeader(http.StatusNotFound) and then uses json.NewEncoder(w).Encode(...)
and on encode error calls http.Error, which cannot change the already-sent
status; instead either (A) marshal/encode the JSON into a buffer first (use
json.Marshal or json.NewEncoder(&buf).Encode) and only after successful encoding
set w.Header().Set("Content-Type", "application/json"), call
w.WriteHeader(http.StatusNotFound), and write the buffer to w, or (B) if you
prefer streaming with json.NewEncoder(w).Encode, remove the http.Error call and
log the encoding error (e.g., log.Printf or your package logger) because the 404
has already been sent; update the code paths around json.NewEncoder(w).Encode,
w.WriteHeader, and http.Error accordingly.

In `@pkg/help/stemmer_test.go`:
- Around line 5-6: Remove the dot-import of "dappco.re/go" in
pkg/help/stemmer_test.go and add explicit imports for
"github.com/stretchr/testify/assert" and "github.com/stretchr/testify/require";
then update all test and benchmark functions (those using *T, *B and the
dot-imported helpers like Assert* and Require*) to use the standard testify
calls (assert.* and require.*) and the local testing objects (t *testing.T, b
*testing.B) instead of the dot-imported helpers so the file follows the
repository guideline.

---

Outside diff comments:
In `@go.mod`:
- Line 1: The module declaration in go.mod is incorrect; open go.mod and replace
the module path string "dappco.re/go/core/docs" with the required module name
"forge.lthn.ai/core/docs" so the module directive (the module line at the top of
go.mod) matches the coding guidelines and the rest of the project.

In `@pkg/help/ingest_test.go`:
- Line 1: The SPDX header contains a typo "SPDX-Licence-Identifier" — update it
to the correct token "SPDX-License-Identifier" in pkg/help/ingest_test.go (the
file-level header string) so the SPDX header reads "SPDX-License-Identifier:
EUPL-1.2".

In `@pkg/help/layout.go`:
- Around line 413-414: The snippet r.Snippet is written directly into HTML via
content.WriteString(fmt.Sprintf(`<p>%s</p>`, r.Snippet)) which can lead to XSS
or broken rendering; fix by HTML-escaping the snippet before insertion (e.g.,
use html.EscapeString on r.Snippet or render with text/template/htmlescape
utilities) and then write the escaped value into content (update the code around
content.WriteString and the use of r.Snippet accordingly so the output is safe).
- Line 1: The SPDX header at the top of pkg/help/layout.go currently reads
"SPDX-Licence-Identifier: EUPL-1.2" (typo "Licence"); update that top-of-file
header string to "SPDX-License-Identifier: EUPL-1.2" and make the identical fix
in server.go where the same header appears so both files use the correct
SPDX-License-Identifier spelling.

In `@pkg/help/parser_test.go`:
- Line 1: The SPDX header string "SPDX-Licence-Identifier: EUPL-1.2" contains a
typo ("Licence"); replace it with the correct identifier
"SPDX-License-Identifier: EUPL-1.2" wherever it appears (e.g., at the top of
parser_test.go) so the SPDX tag is valid and parsers/tools recognize the
license.

In `@pkg/help/search_test.go`:
- Line 1: Update the SPDX header string "SPDX-Licence-Identifier: EUPL-1.2" to
the correct spelling "SPDX-License-Identifier: EUPL-1.2" (replace "Licence" with
"License") so the SPDX identifier is valid across the repository; ensure the
same correction is applied wherever the exact token "SPDX-Licence-Identifier:
EUPL-1.2" appears.

In `@pkg/help/server.go`:
- Line 1: Update the SPDX header string at the top of the file by correcting the
typo "Licence" to the standard SPDX identifier spelling "License" so the header
reads "SPDX-License-Identifier: EUPL-1.2"; locate and edit the existing header
comment in pkg/help/server.go (the top-of-file SPDX comment) to perform this
single-word fix.

In `@pkg/help/templates_test.go`:
- Line 1: Fix the SPDX header typo by changing the token
"SPDX-Licence-Identifier: EUPL-1.2" to the correct "SPDX-License-Identifier:
EUPL-1.2" so the SPDX identifier uses "License" (update the string that
currently reads "SPDX-Licence-Identifier" in the file).

---

Nitpick comments:
In `@pkg/help/ax7_test.go`:
- Around line 39-636: This AX7 omnibus test suite duplicates tests already
present in catalog_test.go, generate_test.go, layout_test.go, render_test.go,
and server_test.go; remove this redundant file (or prune it) and move any unique
edge-case tests into the focused test files that cover the relevant area: e.g.
move Topic/Index/Search edge cases to catalog_test.go (tests referencing
Catalog, newSearchIndex, Tokens, Search, Add), move generation/output edge cases
to generate_test.go (tests referencing Generate, RenderIndexPage,
RenderTopicPage, RenderSearchPage, Render404Page, RenderMarkdown), and move
HTTP/server edge cases to server_test.go (tests referencing NewServer,
Server.ListenAndServe, ServeHTTP); ensure each moved test keeps its assertions
and uses the existing helper funcs (ax7Catalog, ax7Topic) so there is no
behavioral duplication across test files.

In `@pkg/help/parser_test.go`:
- Around line 641-646: The test TestExtractSections_Bad_EmptyString redundantly
asserts the same emptiness condition three times; simplify by keeping a single
clear assertion (e.g., AssertEmpty) and removing the duplicate AssertLen and
AssertFalse checks. Update the test body for TestExtractSections_Bad_EmptyString
to call ExtractSections("") once and assert emptiness via AssertEmpty(t,
sections) (or a single AssertLen(t, sections, 0)) and remove AssertLen and
AssertFalse to avoid duplicated checks.
- Around line 675-680: In TestGenerateID_Ugly_EmptyString, remove the redundant
assertions so the test only asserts emptiness: drop AssertEqual(t, "", result)
and AssertNotContains(t, result, "-") and keep a single AssertEmpty(t, result)
(references: TestGenerateID_Ugly_EmptyString, AssertEqual, AssertEmpty,
AssertNotContains).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 790dd869-29b0-49bf-a4de-f02efcc5fa90

📥 Commits

Reviewing files that changed from the base of the PR and between 50fc1be and 0f1eb52.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (17)
  • go.mod
  • pkg/help/ax7_test.go
  • pkg/help/catalog.go
  • pkg/help/catalog_test.go
  • pkg/help/generate_test.go
  • pkg/help/ingest_test.go
  • pkg/help/integration_test.go
  • pkg/help/layout.go
  • pkg/help/layout_test.go
  • pkg/help/parser_test.go
  • pkg/help/render_test.go
  • pkg/help/search_bench_test.go
  • pkg/help/search_test.go
  • pkg/help/server.go
  • pkg/help/server_test.go
  • pkg/help/stemmer_test.go
  • pkg/help/templates_test.go

Comment thread pkg/help/ax7_test.go
Comment on lines +1 to +10
package help

import (
. "dappco.re/go"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"slices"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add the SPDX header to this new file.

pkg/help/ax7_test.go is new, but it does not carry the required EUPL SPDX header at the top.

📌 Proposed fix
+// SPDX-License-Identifier: EUPL-1.2
 package help

As per coding guidelines, pkg/**/*.go: Use SPDX headers (EUPL-1.2 license) in source files.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
package help
import (
. "dappco.re/go"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"slices"
)
// SPDX-License-Identifier: EUPL-1.2
package help
import (
. "dappco.re/go"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"slices"
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/help/ax7_test.go` around lines 1 - 10, This new test file in package help
is missing the required SPDX EUPL-1.2 header; add the standard SPDX header
comment block (EUPL-1.2 license identifier and any required copyright line) at
the very top of ax7_test.go immediately before the "package help" declaration so
the file complies with the pkg/**/*.go SPDX header guideline.

Comment thread pkg/help/catalog.go
Comment on lines 1 to 2
package help

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing SPDX license header.

As per coding guidelines, source files in pkg/**/*.go should include an SPDX header with the EUPL-1.2 licence.

Proposed fix
+// SPDX-License-Identifier: EUPL-1.2
 package help
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
package help
// SPDX-License-Identifier: EUPL-1.2
package help
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/help/catalog.go` around lines 1 - 2, Add the required SPDX license header
for EUPL-1.2 at the top of the source file so the package declaration (package
help) is preceded by the SPDX comment block; update the header to match the
project's standard SPDX format for pkg/**/*.go files and ensure it is placed
before any package or import statements to satisfy licensing checks.

Comment thread pkg/help/server_test.go
Comment on lines 4 to 9
import (
. "dappco.re/go"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify which Go test files under pkg/help switched to dappco.re/go helpers
# without retaining the repo-standard testify imports.

fd -e go . pkg/help | while read -r f; do
  [[ "$f" == *_test.go ]] || continue
  if rg -q '^\s*\. "dappco\.re/go"' "$f" && ! rg -q 'github\.com/stretchr/testify/(assert|require)' "$f"; then
    printf '%s\n' "$f"
  fi
done

Repository: dAppCore/docs

Length of output: 384


Restore testify to Go test files.

This change migrates 13 test files in pkg/help/ from the repo-standard testify/assert and testify/require to dot-imported dappco.re/go helpers, violating the coding guideline: **/*_test.go: Use testify/assert and testify/require for test assertions in Go tests. Either restore testify across all migrated test files or update the guideline in this PR.

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

In `@pkg/help/server_test.go` around lines 4 - 9, The tests in
pkg/help/server_test.go (and the other migrated files) use a dot-import of
dappco.re/go instead of the repo-standard testify; revert the import to use
"github.com/stretchr/testify/assert" and "github.com/stretchr/testify/require"
(remove . "dappco.re/go"), then update assertion calls in functions like those
in server_test.go to call assert.* and require.* as appropriate; apply the same
replacement across the other 12 migrated test files to restore consistent use of
testify.

Comment thread pkg/help/server.go
Comment on lines 117 to 122
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(map[string]string{"error": "topic not found"})
if err := json.NewEncoder(w).Encode(map[string]string{"error": "topic not found"}); err != nil {
http.Error(w, "Internal server error", http.StatusInternalServerError)
}
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

http.Error after WriteHeader will not set status code correctly.

Once WriteHeader(http.StatusNotFound) is called on line 118, subsequent calls to http.Error on line 120 cannot change the status code to 500. The response will still have status 404 but with an "Internal server error" body, which is confusing. If JSON encoding fails after headers are sent, consider logging the error instead.

Proposed fix
 	if err != nil {
 		w.Header().Set("Content-Type", "application/json")
 		w.WriteHeader(http.StatusNotFound)
-		if err := json.NewEncoder(w).Encode(map[string]string{"error": "topic not found"}); err != nil {
-			http.Error(w, "Internal server error", http.StatusInternalServerError)
-		}
+		_ = json.NewEncoder(w).Encode(map[string]string{"error": "topic not found"})
 		return
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(map[string]string{"error": "topic not found"})
if err := json.NewEncoder(w).Encode(map[string]string{"error": "topic not found"}); err != nil {
http.Error(w, "Internal server error", http.StatusInternalServerError)
}
return
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(map[string]string{"error": "topic not found"})
return
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/help/server.go` around lines 117 - 122, The current handler calls
w.WriteHeader(http.StatusNotFound) and then uses json.NewEncoder(w).Encode(...)
and on encode error calls http.Error, which cannot change the already-sent
status; instead either (A) marshal/encode the JSON into a buffer first (use
json.Marshal or json.NewEncoder(&buf).Encode) and only after successful encoding
set w.Header().Set("Content-Type", "application/json"), call
w.WriteHeader(http.StatusNotFound), and write the buffer to w, or (B) if you
prefer streaming with json.NewEncoder(w).Encode, remove the http.Error call and
log the encoding error (e.g., log.Printf or your package logger) because the 404
has already been sent; update the code paths around json.NewEncoder(w).Encode,
w.WriteHeader, and http.Error accordingly.

Comment thread pkg/help/server.go
Comment on lines 135 to 141
if query == "" {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
_ = json.NewEncoder(w).Encode(map[string]string{"error": "missing query parameter 'q'"})
if err := json.NewEncoder(w).Encode(map[string]string{"error": "missing query parameter 'q'"}); err != nil {
http.Error(w, "Internal server error", http.StatusInternalServerError)
}
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Same issue: http.Error after WriteHeader is ineffective.

The WriteHeader(http.StatusBadRequest) on line 137 prevents http.Error on line 139 from setting status 500. The client will receive a 400 response with "Internal server error" text.

Proposed fix
 	if query == "" {
 		w.Header().Set("Content-Type", "application/json")
 		w.WriteHeader(http.StatusBadRequest)
-		if err := json.NewEncoder(w).Encode(map[string]string{"error": "missing query parameter 'q'"}); err != nil {
-			http.Error(w, "Internal server error", http.StatusInternalServerError)
-		}
+		_ = json.NewEncoder(w).Encode(map[string]string{"error": "missing query parameter 'q'"})
 		return
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if query == "" {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
_ = json.NewEncoder(w).Encode(map[string]string{"error": "missing query parameter 'q'"})
if err := json.NewEncoder(w).Encode(map[string]string{"error": "missing query parameter 'q'"}); err != nil {
http.Error(w, "Internal server error", http.StatusInternalServerError)
}
return
if query == "" {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
_ = json.NewEncoder(w).Encode(map[string]string{"error": "missing query parameter 'q'"})
return
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/help/server.go` around lines 135 - 141, Replace the current double-write
status flow when query == "" so you don't call http.Error after already calling
WriteHeader: either (A) use http.Error to send the 400 with a plain text message
(e.g. http.Error(w, "missing query parameter 'q'", http.StatusBadRequest)) and
remove WriteHeader/Encode, or (B) keep the JSON response path but do not call
WriteHeader before a potential fallback http.Error — instead set the status only
when you know encoding succeeded and on encode failure log the error and write a
500 (e.g. call w.WriteHeader(http.StatusInternalServerError) before writing the
error body). Update the branch that uses json.NewEncoder(w).Encode(...)
accordingly so a second http.Error is never invoked after WriteHeader.

Comment thread pkg/help/stemmer_test.go
Comment on lines +5 to 6
. "dappco.re/go"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify this file does not rely on dappco.re/go test helpers.
rg -n '^\s*\.\s*"dappco\.re/go"|func\s+\w+\(.*\*T\)|func\s+\w+\(.*\*B\)|\bAssert[A-Z]|\bRequire[A-Z]' pkg/help/stemmer_test.go

# Verify testify imports/assertions are present.
rg -n 'github\.com/stretchr/testify/(assert|require)|\bassert\.|\brequire\.' pkg/help/stemmer_test.go

Repository: dAppCore/docs

Length of output: 1874


Restore testify/assert and testify/require in this test file.

The code uses dot-imported dappco.re/go helpers (*T, *B, Assert*, Require*) which conflicts with the repository's coding guideline requiring testify/assert and testify/require for **/*_test.go files.

Representative fix pattern
 import (
-	. "dappco.re/go"
+	"testing"
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 )

-func TestStem_Good(t *T) {
+func TestStem_Good(t *testing.T) {
@@
-		t.Run(tt.name, func(t *T) {
+		t.Run(tt.name, func(t *testing.T) {
 			result := stem(tt.input)
-			AssertEqual(t, tt.expected, result)
+			assert.Equal(t, tt.expected, result)
 		})
 	}
 }

Also applies to lines: 12–221 (all test and benchmark functions).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
. "dappco.re/go"
)
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/help/stemmer_test.go` around lines 5 - 6, Remove the dot-import of
"dappco.re/go" in pkg/help/stemmer_test.go and add explicit imports for
"github.com/stretchr/testify/assert" and "github.com/stretchr/testify/require";
then update all test and benchmark functions (those using *T, *B and the
dot-imported helpers like Assert* and Require*) to use the standard testify
calls (assert.* and require.*) and the local testing objects (t *testing.T, b
*testing.B) instead of the dot-imported helpers so the file follows the
repository guideline.

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