API.html: the `Remove Properties` example calls `/api/set`, and `Patch Update` documents `null` as storing null
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- api, documentation
調査の方向性
public/API.html の Patch Update と Remove Properties の例から始め、その文言と URL を controllers/patchUpdate.js、controllers/patchUnset.js、routes/api-routes.js と比較します。削除の例で /api/unset を使用し、null の動作が削除としてドキュメント化され、周辺のエンドポイント例が一貫していれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
Two PATCH sections of public/API.html contradict the controllers they document. Both are in the copy-paste path, and one of them documents the wrong endpoint entirely.
- The
Remove PropertiesJavascript example calls/api/set. The section documents/unset, its prose is right, and its payload is an unset payload — but thefetchURL ishttps://devstore.rerum.io/v1/api/set. Anyone copying the example sends a removal payload to the add-only endpoint. Patch Updatedocuments{"key": null}as storing null. It says the value "will be set to null instead of removing the property".controllers/patchUpdate.jsdeletes the key.
The third API.html error I found — the default of 10 records at line 506 — is already tracked in #305, so it is not repeated here.
Why this matters
The /unset example is the wrong endpoint, not a typo in prose. routes/patchUnset.js serves /api/unset (mounted at routes/api-routes.js:61), and GET /v1/api describes /unset as "PATCH - Update the body an existing object by removing an existing property." The example's own body — "existing_property": null with an "unmatched_property" noted as ignored — is exactly the unset contract described three lines above it. Sent to /api/set it is a silent no-op: controllers/patchSet.js keeps only keys that are not already present, so existing_property is filtered out, nothing survives, and the server returns the original object with a 200 and the same @id. The caller sees success and the property is still there.
Copy-paste is the documented path. These blocks are the worked examples for the endpoint, and they are extracted verbatim by downstream consumers. A tool of ours that builds a corpus from API.html ingested this example and learned /api/set as the endpoint for removing a property; that is our bug to fix on our side, but it is evidence that the block travels intact.
The null claim is inverted, and null is load-bearing for both endpoints. controllers/patchUpdate.js:58-63 branches on the value:
for (let k in objectReceived) {
if (originalObject.hasOwnProperty(k)) {
if (objectReceived[k] === null) {
delete patchedObject[k]
}
else {
patchedObject[k] = objectReceived[k]
}
}
So /patch with null removes the key. /unset requires null to remove anything at all (controllers/patchUnset.js:61-70), which Remove Properties states correctly. A reader who trusts Patch Update believes RERUM stores JSON nulls, which it never does through this route.
Affected lines
All line numbers at 8e4b673d.
| File | Line | Current | Should be |
|---|---|---|---|
public/API.html |
1413 | fetch("https://devstore.rerum.io/v1/api/set", { in the Remove Properties example |
.../v1/api/unset |
public/API.html |
1249-1250 | "If {"key":null} is submitted, the value for property "key" will be set to null instead of removing the property." |
the key is removed from the new version |
Proposed change
API.html:1413— change the URL tohttps://devstore.rerum.io/v1/api/unset. Nothing else in the block needs to move; the payload and the surrounding prose already describe/unset.API.html:1249-1250— replace with a sentence matching the controller, e.g. "If{"key":null}is submitted, propertykeyis removed from the resulting record. To change a value, send the new value; to add a key that does not exist yet, use/set."- Worth a pass over the other
jsExampleblocks for the same class of error: each example's URL should be checked against the endpoint its section documents. These two were found by diffing the examples against the controllers rather than by reading the page.
- 主要言語
- JavaScript
- スター
- 3
- フォーク
- 6
- 平均マージ
- 4日 9時間
- マージ済み PR(30日)
- 5
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CenterForDigitalHumanities/rerum_server_nodejs のほかの issue
-
backend dependencies easy
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
CenterForDigitalHumanities/rerum_server_nodejs#290 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
-
Code Cleanup Epicオープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
CenterForDigitalHumanities/rerum_server_nodejs の issue をすべて見る
似ている issue
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
amponce/archive-movie-browser#354 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
saayam-for-all/webapp#1870 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Imageomics/OpenCite#66 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
chr15m/twiiit.com#20 ·
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
antropos17/Aegis#629 ·
メンテナーはふだん 4 日以内に返信