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(nlp): send "language" to the v1 analyzeEntities call

Switch Case Studio5bf26087ff90
diff --git a/scripts/nlp_analyze.py b/scripts/nlp_analyze.py
index 55f2ce4..c3a1b40 100644
--- a/scripts/nlp_analyze.py
+++ b/scripts/nlp_analyze.py
@@ -97,13 +97,19 @@ def analyze_text(
"content": text[:100000], # API limit
"languageCode": language,
}
+ # v1 names the field "language" and rejects "languageCode" with HTTP 400.
+ v1_document = {
+ "type": "PLAIN_TEXT",
+ "content": document["content"],
+ "language": language,
+ }
# Entities still use v1 because it returns Knowledge Graph metadata
# and salience consistently. Other features stay on v2 annotateText.
wants_entities = "entities" in features
if wants_entities:
body = {
- "document": document,
+ "document": v1_document,
"encodingType": "UTF8",
}
try:
diff --git a/tests/test_nlp_analyze.py b/tests/test_nlp_analyze.py
index a77df96..7521765 100644
--- a/tests/test_nlp_analyze.py
+++ b/tests/test_nlp_analyze.py
@@ -89,3 +89,31 @@ def test_entities_only_skips_v2_annotate_text_call() -> None:
assert calls == [nlp_analyze.NLP_V1_ENTITIES_ENDPOINT]
assert result["error"] is None
+
+
+def test_each_endpoint_gets_its_own_language_field_name() -> None:
+ """v1 analyzeEntities names the field "language" and rejects "languageCode"
+ with HTTP 400; v2 annotateText names it "languageCode"."""
+ bodies: dict[str, dict] = {}
+
+ def fake_post(url: str, **kwargs):
+ bodies[url] = kwargs["json"]
+ if url == nlp_analyze.NLP_V1_ENTITIES_ENDPOINT:
+ return FakeResponse({"entities": []})
+ return FakeResponse({"documentSentiment": {"score": 0.0, "magnitude": 0.0}})
+
+ with patch.object(nlp_analyze.requests, "post", side_effect=fake_post):
+ nlp_analyze.analyze_text(
+ "O Quénia tem corredores de maratona.",
+ features=["entities", "sentiment"],
+ api_key="AI" + "zaSyDUMMYSECRET",
+ language="pt",
+ )
+
+ v1_document = bodies[nlp_analyze.NLP_V1_ENTITIES_ENDPOINT]["document"]
+ v2_document = bodies[nlp_analyze.NLP_ENDPOINT]["document"]
+ assert v1_document["language"] == "pt"
+ assert "languageCode" not in v1_document
+ assert v2_document["languageCode"] == "pt"
+ assert "language" not in v2_document
+ assert v1_document["content"] == v2_document["content"]