Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

fix(indexnow): report submission errors in text mode

zhang.kom8e0313481aee
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 648be42..743f0a2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+
+- Report IndexNow submission errors in text mode without raising a KeyError.
+
## [2.5.0] - 2026-10-22
Security and accuracy fixes from a full audit, and Claude Desktop installs again.
diff --git a/scripts/indexnow_submit.py b/scripts/indexnow_submit.py
index 59a8042..6a77d72 100644
--- a/scripts/indexnow_submit.py
+++ b/scripts/indexnow_submit.py
@@ -247,7 +247,9 @@ def main() -> int:
else:
status = "OK" if result["ok"] else "FAIL"
print(f"IndexNow: {status} (status={result.get('status_code')})")
- print(f" Submitted: {result['submitted']} URLs to {result['endpoint']}")
+ endpoint = result.get("endpoint")
+ destination = f" to {endpoint}" if endpoint else ""
+ print(f" Submitted: {result['submitted']} URLs{destination}")
if result.get("engines"):
print(f" Engines: {', '.join(result['engines'])}")
if not result["ok"]:
diff --git a/tests/test_indexnow_cli_errors.py b/tests/test_indexnow_cli_errors.py
new file mode 100644
index 0000000..001a972
--- /dev/null
+++ b/tests/test_indexnow_cli_errors.py
@@ -0,0 +1,61 @@
+import json
+import sys
+from pathlib import Path
+from unittest.mock import patch
+
+import pytest
+import requests
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
+import indexnow_submit # noqa: E402
+
+
+ ("key", "url", "post_error", "expected"),
+ [
+ ("short", "https://example.com/a", None, "key must be"),
+ ("validkey", "https://other.test/a", None, "don't belong to host"),
+ ("validkey", "https://example.com/a", "offline", "HTTP error: offline"),
+ ],
+)
+def test_text_output_reports_submission_errors(monkeypatch, capsys, key, url, post_error, expected):
+ monkeypatch.setattr(
+ sys, "argv", ["indexnow_submit.py", "--host", "example.com", "--key", key,
+ "--key-location", "https://example.com/key.txt", "--urls", url]
+ )
+ monkeypatch.setattr(indexnow_submit, "verify_key_published", lambda *_: {"ok": True})
+ monkeypatch.setattr(indexnow_submit, "validate_url_strict", lambda _: None)
+ with patch.object(requests, "post", side_effect=requests.ConnectionError(post_error)):
+ assert indexnow_submit.main() == 1
+ output = capsys.readouterr().out
+ assert "IndexNow: FAIL" in output
+ assert expected in output
+
+
+def test_json_output_preserves_error_details(monkeypatch, capsys):
+ monkeypatch.setattr(
+ sys, "argv", ["indexnow_submit.py", "--host", "example.com", "--key", "short",
+ "--key-location", "https://example.com/key.txt", "--urls",
+ "https://example.com/a", "--json"]
+ )
+ monkeypatch.setattr(indexnow_submit, "verify_key_published", lambda *_: {"ok": True})
+ assert indexnow_submit.main() == 1
+ result = json.loads(capsys.readouterr().out)
+ assert result["ok"] is False
+ assert "key must be" in result["error"]
+
+
+def test_text_output_keeps_endpoint_when_server_responds(monkeypatch, capsys):
+ monkeypatch.setattr(
+ sys, "argv", ["indexnow_submit.py", "--host", "example.com", "--key", "validkey",
+ "--key-location", "https://example.com/key.txt", "--urls",
+ "https://example.com/a"]
+ )
+ monkeypatch.setattr(indexnow_submit, "verify_key_published", lambda *_: {"ok": True})
+ monkeypatch.setattr(indexnow_submit, "validate_url_strict", lambda _: None)
+ with patch.object(requests, "post") as post:
+ post.return_value.status_code = 202
+ post.return_value.text = ""
+ assert indexnow_submit.main() == 0
+ output = capsys.readouterr().out
+ assert "Submitted: 1 URLs to https://api.indexnow.org/indexnow" in output