test(metadata): apiMetadata npm-fields round-trip test [#847] #848

Merged
jmiller merged 1 commits from fix/apimetadata-npm-fields into dev 2026-07-20 14:37:50 +00:00
Owner

Summary

Fixes #847 (regression class from #827): the npm/mcp metadata fields npm_package, node_minimum, and publish_target must round-trip over GET/PUT /api/v1/repos/{owner}/{repo}/metadata.

Investigation

On dev, the handler in routers/api/v1/repo/manifest.go already declares all three fields on the apiMetadata struct and wires both directions:

  • GET: copies m.NodeMinimum / m.NpmPackage / m.PublishTarget into the response.
  • PUT: setStr("node_minimum"/"npm_package"/"publish_target", ...) partial-merge persists them.

The underlying model (models/repo/repo_manifest.go) and migration (models/migrations/v1_27/v373.go) define the columns:

Go field xorm/db column
NpmPackage TEXT 'npm_package'
NodeMinimum VARCHAR(20) 'node_minimum'
PublishTarget VARCHAR(50) 'publish_target'

This landed in commit 5f85b27 (feat(metadata): persist npm/mcp fields ... [#363]). The bug reported in #847 was observed on prod, which lags dev; on dev the serialization/persistence is already correct.

What this PR adds

No round-trip test guarded the behavior, so a future refactor of the fixed-shape apiMetadata struct could silently reintroduce #847. This PR adds tests/integration/api_repo_metadata_test.goTestAPIRepoMetadataNpmFieldsRoundTrip — which PUTs the three fields (as admin user1, matching the reqAdmin() gate) and asserts they are echoed by the PUT response and read back by a subsequent GET.

Notes

  • UNBUILT: no Go toolchain in this environment. Formatting matched by hand (tabs, aligned tags). Owner builds/deploys forge Go.
  • Draft / WIP pending build + prod catch-up from dev.

Refs #847, #827.

https://claude.ai/code/session_015UauDPfYC8S2mdUhoSK8zQ

## Summary Fixes #847 (regression class from #827): the npm/mcp metadata fields `npm_package`, `node_minimum`, and `publish_target` must round-trip over `GET`/`PUT /api/v1/repos/{owner}/{repo}/metadata`. ## Investigation On `dev`, the handler in `routers/api/v1/repo/manifest.go` **already** declares all three fields on the `apiMetadata` struct and wires **both** directions: - GET: copies `m.NodeMinimum` / `m.NpmPackage` / `m.PublishTarget` into the response. - PUT: `setStr("node_minimum"/"npm_package"/"publish_target", ...)` partial-merge persists them. The underlying model (`models/repo/repo_manifest.go`) and migration (`models/migrations/v1_27/v373.go`) define the columns: | Go field | xorm/db column | | --- | --- | | `NpmPackage` | `TEXT 'npm_package'` | | `NodeMinimum` | `VARCHAR(20) 'node_minimum'` | | `PublishTarget` | `VARCHAR(50) 'publish_target'` | This landed in commit `5f85b27` (`feat(metadata): persist npm/mcp fields ... [#363]`). The bug reported in #847 was observed on **prod**, which lags `dev`; on `dev` the serialization/persistence is already correct. ## What this PR adds No round-trip test guarded the behavior, so a future refactor of the fixed-shape `apiMetadata` struct could silently reintroduce #847. This PR adds `tests/integration/api_repo_metadata_test.go` — `TestAPIRepoMetadataNpmFieldsRoundTrip` — which PUTs the three fields (as admin `user1`, matching the `reqAdmin()` gate) and asserts they are echoed by the PUT response and read back by a subsequent GET. ## Notes - **UNBUILT**: no Go toolchain in this environment. Formatting matched by hand (tabs, aligned tags). Owner builds/deploys forge Go. - Draft / WIP pending build + prod catch-up from `dev`. Refs #847, #827. https://claude.ai/code/session_015UauDPfYC8S2mdUhoSK8zQ
jmiller added 1 commit 2026-07-20 13:42:20 +00:00
fix(metadata): serialize npm/mcp fields in apiMetadata (npm_package/node_minimum/publish_target) [#847]
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 44s
Generic: Project CI / Tests (pull_request) Successful in 29s
Generic: Project CI / Lint & Validate (pull_request) Successful in 34s
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: PR Check / Require Docs Update (pull_request) Has been skipped
Universal: PR Check / Wiki Update Reminder (pull_request) Has been skipped
Universal: PR Check / Validate PR (pull_request) Successful in 9s
Branch Cleanup / Delete merged branch (pull_request) Successful in 2s
Universal: PR Check / Secret Scan (pull_request) Successful in 40s
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
92d7d5563b
The GET/PUT /api/v1/repos/{owner}/{repo}/metadata handler already declares
node_minimum, npm_package and publish_target on the apiMetadata struct and
wires both the GET-serialize and PUT-persist paths (commit 5f85b27, #363).
No round-trip test guarded that behavior, so a regression could silently
reintroduce #847 (from #827) where these DB columns are un-settable and
un-readable over the REST API.

Add an integration test that PUTs the three fields and asserts they are
echoed by the PUT response and read back by a subsequent GET.

Authored-by: Moko Consulting
jmiller changed title from WIP: fix(metadata): guard npm/mcp field round-trip in apiMetadata [#847] to test(metadata): apiMetadata npm-fields round-trip test [#847] 2026-07-20 14:37:38 +00:00
jmiller merged commit 154c3f77e4 into dev 2026-07-20 14:37:50 +00:00
jmiller deleted branch fix/apimetadata-npm-fields 2026-07-20 14:37:51 +00:00
Sign in to join this conversation.