script: More error checks and logging
What changed, and why it matters
This is a routine improvement to a GitHub automation script that synchronizes documentation to a third-party service (ReadMe). It adds basic safety checks—verifying an API key is present, confirming files exist before opening them, and switching from document 'title' to 'slug' for matching. There is no indication this fixes a security vulnerability in the Core Lightning software itself; it simply makes a docs-publishing script fail more gracefully and avoid some accidental mismatches or crashes.
No security action required. Treat as a normal maintenance/docs-CI improvement. Reviewers may optionally confirm the slug field is always present and unique in the ReadMe API responses, since the script now relies on it.
Security signals we found
Added missing-credential guard for README_API_KEY
Added file-existence checks before file reads
Switched remote identifier from 'title' to 'slug' to avoid mismatches
No change to network-facing daemon, wallet, cryptography, or protocol handling
Evidence from the diff
The patch modifies .github/scripts/sync-rpc-cmds.py, a CI/maintenance script that publishes RPC command docs to ReadMe. Changes: (1) validate README_API_KEY env var before use; (2) check doc/index.rst exists before reading; (3) use command[‘slug’] instead of command[‘title’] when comparing local docs against remote entries; (4) check each referenced manpage file exists before opening; (5) reduce DELETE sleep from 3s to 1s and add completion logging. The slug-vs-title change is the most substantive: it aligns local/remote identifier matching, which could previously cause incorrect add/delete decisions if titles and slugs diverged. The new checks prevent unhandled FileNotFoundError/KeyError exceptions and clearer missing-credential failures.
Changed components
.github/scripts/sync-rpc-cmds.pyInspect captured patch +22 / −5
diff --git a/.github/scripts/sync-rpc-cmds.py b/.github/scripts/sync-rpc-cmds.py
index 1657900d..368f37a0 100644
--- a/.github/scripts/sync-rpc-cmds.py
+++ b/.github/scripts/sync-rpc-cmds.py
@@ -35,7 +35,7 @@ def check_renderable(response, action, title):
renderable = data.get("renderable")
if renderable is None:
- # Some endpoints don’t include renderable (e.g. DELETE)
+ # Some endpoints don't include renderable (e.g. DELETE)
return True
if not renderable.get("status", False):
@@ -121,8 +121,18 @@ def main():
"Authorization": "Bearer " + os.environ.get("README_API_KEY"),
}
+ # Validate API key exists
+ if not os.environ.get("README_API_KEY"):
+ print("❌ ERROR: README_API_KEY environment variable not set")
+ return
+
# path to the rst file from where we fetch all the RPC commands
path_to_rst = "doc/index.rst"
+
+ if not os.path.exists(path_to_rst):
+ print(f"❌ ERROR: File not found: {path_to_rst}")
+ return
+
with open(path_to_rst, "r") as file:
rst_content = file.read()
@@ -131,24 +141,31 @@ def main():
# Compare local and server commands list to get the list of command to add or delete
commands_local_title = set(command[0] for command in commands_from_local)
- commands_readme_title = set(command['title'] for command in commands_from_readme)
+ commands_readme_title = set(command['slug'] for command in commands_from_readme)
commands_to_delete = commands_readme_title - commands_local_title
commands_to_add = commands_local_title - commands_readme_title
for name in commands_to_delete:
publishDoc(Action.DELETE, name, "", 0, headers)
- sleep(3)
+ sleep(1)
if commands_from_local:
position = 0
for name, file in commands_from_local:
- with open("doc/" + file) as f:
+ file_path = "doc/" + file
+ if not os.path.exists(file_path):
+ print(f"⚠️ WARNING: File not found: {file_path}, skipping {name}")
+ continue
+
+ with open(file_path) as f:
body = f.read()
action = Action.ADD if name in commands_to_add else Action.UPDATE
publishDoc(action, name, body, position, headers)
position += 1
sleep(1)
else:
- print("No commands found in the Manpages block.")
+ print("⚠️ No commands found in the Manpages block.")
+
+ print("\n✨ Sync complete!")
if __name__ == "__main__":
Why this scored 18/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.