Skip to content

fix(seo): default analysisType to full in wp_seo_analyze_content - #268

Merged
docdyhr merged 6 commits into
mainfrom
fix/seo-analyze-default-type
Oct 10, 2026
Merged

docdyhr merged 6 commits into
mainfrom
fix/seo-analyze-default-type

Conversation

@docdyhr

@docdyhr docdyhr commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Pull Request

Description

wp_seo_analyze_content failed without analysisType: Failed to analyze content: Missing required parameters: analysisType. The tool schema requires only postId and describes analysisType as optional ("default: full"), but SEOTools.analyzeContent() validated it as required. This is the regression reported in the v4.0.9 re-test results.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Changes Made

  • SEOTools.analyzeContent() applies the documented default (analysisType ?? "full") before validating, and validates only postId. Because the default is applied before the cache key is built, an omitted type and an explicit "full" share one cached analysis.
  • src/tools/AGENTS.md: a handler's validateRequired() list must not be stricter than the schema's required, and an optional property whose description names a default gets that default in code. Review follow-up (b40d835): two descriptions named defaults the code never applied. wp_seo_suggest_internal_links maxSuggestions said 5 and the code uses 10; wp_seo_site_audit maxPages said 100 and the code uses 50 (50 posts and 50 pages). The descriptions now name the real defaults (no behaviour change), and docs/api is regenerated. All other (default: …) descriptions in src/tools match their handlers.
  • New tests/tools/seo/SEOToolsAnalyzeContent.test.js (5 tests): the schema keeps analysisType optional; calls without it work directly and through handleAnalyzeContent; the omitted and explicit "full" cases share the cache; postId is still required.

Testing

  • The 3 behaviour tests were red before the change, failing with the exact message from the report
  • Combined run with the other three branches from this pass: 93 files / 2740 tests, lint, typecheck, format:check, security:scan
  • Manual: ran the built server over stdio against site1 and called wp_seo_analyze_content without analysisType on post 1649, which returned an analysis (44 words)

Documentation

  • Documentation updated (src/tools/AGENTS.md)
  • CHANGELOG.md updated — generated by semantic-release

Security

  • No sensitive information committed

Independent review follow-up

  • The content-analysis cache key now includes focusKeywords (in order). It left them out, so a repeat call with other keywords got the earlier keyword analysis back. Test added; red before the fix.
  • The maxPages description notes WordPress's per_page limit of 100; the AGENTS.md rule names where required parameters are checked in code.
  • Not changed here, flagged separately: SEO cache TTLs are written in seconds but CacheManager measures milliseconds, so the 6-hour analysis cache really lasts 21.6 s (this also affects the SEO_CACHE_*_TTL settings). Fixing the units would make results stay cached for hours after a post edit, so it's a behaviour decision for its own change.

🤖 Generated with Claude Code

Summary by Sourcery

Fix SEO content analysis defaults and cache isolation so optional inputs behave consistently with the tool contract.

Bug Fixes:

  • Allow wp_seo_analyze_content to default analysisType to full while continuing to require postId.
  • Prevent cached SEO analyses from being reused across different focus keyword inputs.

Enhancements:

  • Align SEO tool parameter documentation and schema guidance with the defaults implemented by handlers.

Documentation:

  • Regenerate API documentation to reflect the corrected SEO parameter defaults and limits.

Tests:

  • Add regression coverage for optional analysis types, defaulted and cached full analyses, focus-keyword cache isolation, and required post IDs.

The tool schema requires only postId and documents analysisType as
optional ("default: full"), but SEOTools.analyzeContent() validated
analysisType as required, so a call without it failed with "Missing
required parameters: analysisType". Apply the documented default before
validation; an omitted type now shares the cached "full" analysis.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 09:47
@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Sorry @docdyhr, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T09:49:18.206871Z 720962f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Fixes wp_seo_analyze_content so omitted analysisType defaults to full, is validated consistently with the schema, and uses the same cache key as an explicit full request; adds regression tests and contributor guidance.

Sequence diagram for default SEO content analysis

sequenceDiagram
    participant Caller
    participant SEOTools
    participant Cache
    participant WordPress

    Caller->>SEOTools: analyzeContent(client, rawParams)
    SEOTools->>SEOTools: Apply analysisType ?? "full"
    SEOTools->>SEOTools: validateRequired(params, ["postId"])
    SEOTools->>Cache: Lookup seo:analyze:site:postId:full
    alt cached analysis
        Cache-->>SEOTools: SEO analysis result
    else cache miss
        SEOTools->>WordPress: Fetch post content
        WordPress-->>SEOTools: Post content
        SEOTools->>Cache: Store analysis under full key
    end
    SEOTools-->>Caller: SEO analysis result
Loading

File-Level Changes

Change Details Files
Apply the documented analysisType default before validation and cache-key construction.
  • Normalize omitted or null analysisType to full.
  • Relax runtime validation to require only postId.
  • Ensure omitted and explicit full requests share the cache entry.
src/tools/seo/SEOTools.ts
Add regression coverage for schema alignment, default behavior, caching, handler integration, and required-parameter validation.
  • Verify analysisType remains optional in the schema.
  • Cover direct and handler calls without analysisType.
  • Verify missing postId is still rejected.
tests/tools/seo/SEOToolsAnalyzeContent.test.js
Document the invariant that handler validation must not exceed the tool schema and that documented defaults must be implemented in code.
  • Clarify the relationship between schema required fields and validateRequired().
  • Record the default-handling rule for optional properties.
src/tools/AGENTS.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the schema contract and includes focused regression coverage.

0 open findings

What changed in this PR

Fixes SEO analysis calls that omit the optional analysisType, defaulting them to "full" before validation and caching.

Changes:

  • Applies the documented default and preserves postId validation.
  • Adds regression and cache-reuse tests.
  • Documents schema/handler validation consistency.
File Description
src/​tools/​seo/​SEOTools.ts Defaults analysisType before validation and cache-key creation.
tests/​tools/​seo/​SEOToolsAnalyzeContent.test.js Adds regression coverage for defaults, caching, validation, and handler behavior.
src/​tools/​AGENTS.md Documents schema/default handling requirements.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 720962fe8e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tools/AGENTS.md Outdated
wp_seo_suggest_internal_links documented maxSuggestions "default: 5"
and wp_seo_site_audit documented maxPages "default: 100", but the code
applies 10 and 50 (50 posts and 50 pages). The descriptions now name the
real defaults, so the new AGENTS.md rule holds; behaviour is unchanged.
docs/api regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the docs Documentation changes label Oct 9, 2026
docdyhr and others added 3 commits October 9, 2026 13:46
Review follow-up. The analysis cache key left out focusKeywords, but
ContentAnalyzer scores them (the first as primary), so a second call
with other keywords got the first call's keyword analysis back. The
keywords are now part of the key, in order. Also: the maxPages
description notes WordPress's per_page limit of 100, and the AGENTS.md
rule names where required parameters are checked in code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@docdyhr
docdyhr enabled auto-merge (squash) October 10, 2026 20:23
Focus keywords were joined with "," into the analysis cache key, so
["caching,faster"] and ["caching", "faster"] shared a cached result
although the scored primary keyword differs. Key them as JSON instead.

src/tools/AGENTS.md: state the cache-key contract instead of the history
of the old defaults (DOX: contracts, not diary entries).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@docdyhr
docdyhr merged commit 1705144 into main Oct 10, 2026
24 checks passed
@docdyhr
docdyhr deleted the fix/seo-analyze-default-type branch October 10, 2026 21:23
docdyhr pushed a commit that referenced this pull request Oct 10, 2026
## [4.1.1](v4.1.0...v4.1.1) (2026-10-10)

### 🐛 Bug Fixes

* **seo:** default analysisType to full in wp_seo_analyze_content ([#268](#268)) ([1705144](1705144))
@docdyhr

docdyhr commented Oct 10, 2026

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 4.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation changes released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants