script: Update sync RPC documentation script to check if the page was renderable for Readme
What changed, and why it matters
This commit updates an internal GitHub automation script that publishes Core Lightning's JSON-RPC command documentation to the ReadMe documentation platform. It adapts the script to ReadMe's newer API version (using a category web address instead of a numeric ID, wrapping page content differently, and checking whether ReadMe can successfully render each uploaded page). There is no change to the Core Lightning node software, wallet logic, network protocol, or any user-facing runtime behavior. It is purely a documentation-publishing tooling fix.
No security action required. Treat as a normal CI/documentation maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies .github/scripts/sync-rpc-cmds.py. Changes: (1) removes the hardcoded CATEGORY_ID constant and switches the payload’s category field from id to uri formatted as /branches/1/categories/reference/{CATEGORY_SLUG}; (2) wraps the page body under content.body to match ReadMe API v2 expectations; (3) adds a check_renderable() helper that inspects the renderable object in ReadMe v2 responses and prints error/message details, raising RuntimeError if status is false; (4) improves console output with status emojis and early returns on HTTP errors. No Lightning protocol, RPC handler, cryptographic, or networking code is touched.
Changed components
.github/scripts/sync-rpc-cmds.pyInspect captured patch +48 / −13
diff --git a/.github/scripts/sync-rpc-cmds.py b/.github/scripts/sync-rpc-cmds.py
index 6b606354..f1bf8de1 100644
--- a/.github/scripts/sync-rpc-cmds.py
+++ b/.github/scripts/sync-rpc-cmds.py
@@ -7,8 +7,6 @@ from enum import Enum
# readme url
URL = "https://api.readme.com/v2/branches/stable"
-# category id for API reference
-CATEGORY_ID = "685ce4df1df887006ff221c5"
CATEGORY_SLUG = "JSON-RPC API Reference"
@@ -26,39 +24,76 @@ def getListOfRPCDocs(headers):
return []
+def check_renderable(response, action, title):
+ try:
+ data = response.json()
+ except Exception:
+ print("Non-JSON response:")
+ print(response.text)
+ return False
+
+ renderable = data.get("renderable")
+ if renderable is None:
+ # Some endpoints don’t include renderable (e.g. DELETE)
+ return True
+
+ if not renderable.get("status", False):
+ print(f"\n❌ RENDER FAILED for {action.value.upper()} '{title}'")
+ print("Error :", renderable.get("error"))
+ print("Message:", renderable.get("message"))
+ return False
+
+ return True
+
+
def publishDoc(action, title, body, order, headers):
payload = {
"title": title,
"type": "basic",
- "body": body,
+ "content": {
+ "body": body,
+ },
"category": {
- "id": CATEGORY_ID
+ "uri": f"/branches/1/categories/reference/{CATEGORY_SLUG}"
},
"hidden": False,
"order": order,
}
+
if action == Action.ADD:
- # create doc
- payload['slug'] = title
+ payload["slug"] = title
response = requests.post(URL + "/reference", json=payload, headers=headers)
if response.status_code != 201:
+ print("❌ HTTP ERROR:", response.status_code)
print(response.text)
- else:
- print("Created ", title)
+ return
+
+ if not check_renderable(response, action, title):
+ raise RuntimeError(f"Renderable check failed for {title}")
+
+ print("✅ Created", title)
+
elif action == Action.UPDATE:
- # update doc
response = requests.patch(f"{URL}/reference/{title}", json=payload, headers=headers)
if response.status_code != 200:
+ print("❌ HTTP ERROR:", response.status_code)
print(response.text)
- else:
- print("Updated ", title)
+ return
+
+ if not check_renderable(response, action, title):
+ raise RuntimeError(f"Renderable check failed for {title}")
+
+ print("✅ Updated", title)
+
elif action == Action.DELETE:
- # delete doc
response = requests.delete(f"{URL}/reference/{title}", headers=headers)
+
if response.status_code != 204:
+ print("❌ DELETE FAILED:", title)
print(response.text)
else:
- print("Deleted ", title)
+ print("🗑️ Deleted", title)
+
else:
print("Invalid action")
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.