Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(action-center): pass another action's structured data fix only after a check found the page failing (#1680)

Cihan75cbf88d4a1c
diff --git a/docs/guides/action-center.mdx b/docs/guides/action-center.mdx
index 9ae5891fb..6cfe75fb4 100644
--- a/docs/guides/action-center.mdx
+++ b/docs/guides/action-center.mdx
@@ -87,7 +87,7 @@ A task checked **Automatic** is checked on its page, fetched again (up to 200 ta
- **A broken page:** the page answers again.
- **Publishing:** the page answers where it wasn't before. A page already live at the first check passes once it changes.
-- **Structured data:** the audit checks that raised the action now pass on the page, such as a FAQ schema with at least two questions.
+- **Structured data:** the audit checks that raised the action now pass on the page, such as a FAQ schema with at least two questions. When the action was raised by another check (the brand's entity, say), the page's structured data must be valid, after a check found it wasn't: a page that had valid structured data all along says so, and you mark the task done once it's fixed.
- **Crawler access:** robots.txt lets the AI crawlers in, and the page isn't noindex. Only when the audit raised it; a page found uncrawled in the bot logs isn't checked here.
- **Optimizing, refreshing:** the page has changed since it was first checked, by more than a date, a price or a rotating quote moving. On a short page that takes more than a few words.
- **A task written with its new text:** that text is on the page, and the text it replaces is gone.
diff --git a/server/src/lib/action-center/task-checks.js b/server/src/lib/action-center/task-checks.js
index 1532cff93..893f4482f 100644
--- a/server/src/lib/action-center/task-checks.js
+++ b/server/src/lib/action-center/task-checks.js
@@ -98,7 +98,12 @@ const STRUCTURED_MISSING = {
'json-ld-relevance': 'structured_data_irrelevant',
'faq-schema': 'no_faq_schema',
};
-/** A fix raised without the audit's checks named: its JSON-LD must at least be valid. */
+/**
+ * A fix raised without the audit's checks named (another action's, F06's
+ * brand-entity, say): its JSON-LD must at least be valid, and since a page
+ * may have had a valid block all along (a site-wide Organization), it
+ * passes only after a check on the page found it failing (`sawFailing`).
+ */
const DEFAULT_STRUCTURED = ['json-ld-validity'];
/** Checks whose warn is still the problem: a block that doesn't parse. */
const PASS_ONLY = new Set(['json-ld-validity']);
@@ -305,7 +310,7 @@ function changedSince(previous, url, visible) {
const isHtml = (body) => /^\s*(<!doctype\s+html|<html[\s>])/i.test(body ?? '');
/**
- * A task's check on its page: `{ passed, missing, sketch?, wasMissing? }`,
+ * A task's check on its page: `{ passed, missing, sketch?, wasMissing?, sawFailing? }`,
* or null when the page couldn't be read (no answer, a timeout, a server
* error, a 4xx other than "not there", a page nested too deep to parse):
* nothing but the try is kept then.
@@ -357,7 +362,18 @@ export async function checkPage(
const { status } = STRUCTURED_CHECKS[key].evaluate({ $ });
return status === 'fail' || (PASS_ONLY.has(key) && status !== 'pass');
});
- return { passed: !failing.length, missing: failing.map((key) => STRUCTURED_MISSING[key]) };
+ if (failing.length) {
+ return {
+ passed: false,
+ missing: failing.map((key) => STRUCTURED_MISSING[key]),
+ ...(named.length ? {} : { sawFailing: true }),
+ };
+ }
+ // None named, and never seen failing on this page: valid all along, not fixed.
+ if (!named.length && !(previous?.sawFailing && previous.url === url)) {
+ return { passed: false, missing: ['valid_before'] };
+ }
+ return { passed: true, missing: [] };
}
if (kind === 'crawlers') {
@@ -590,6 +606,10 @@ export async function runTaskCheck(task, action, { fetch = fetchPage, now = new
missing: found.missing,
...(kept ? { sketch: kept } : {}),
...(found.wasMissing ? { wasMissing: true } : {}),
+ // Kept for the page, so a fix after a failing check passes.
+ ...(found.sawFailing || (samePageAsBefore && previous?.sawFailing)
+ ? { sawFailing: true }
+ : {}),
...(held ? { held: true } : {}),
}
: { ...(previous ?? {}), triedAt: now.toISOString() };
diff --git a/server/src/lib/action-center/task-checks.test.js b/server/src/lib/action-center/task-checks.test.js
index 9bd8d7168..32b3a7b50 100644
--- a/server/src/lib/action-center/task-checks.test.js
+++ b/server/src/lib/action-center/task-checks.test.js
@@ -267,9 +267,10 @@ describe('checkPage', () => {
const FAQ = ld(
'{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"a"},{"@type":"Question","name":"b"}]}',
);
- const check = (head, auditChecks) =>
+ const check = (head, auditChecks, previous = null) =>
checkPage('structuredData', PAGE, {
auditChecks,
+ previous,
fetch: fetchOf({ [PAGE]: html('x', head) }),
});
// A FAQ schema fix isn't passed by the site's Organization block.
@@ -278,11 +279,21 @@ describe('checkPage', () => {
missing: ['no_faq_schema'],
});
expect(await check(`${ORG}${FAQ}`, ['faq-schema'])).toEqual({ passed: true, missing: [] });
- // No checks named: the JSON-LD must be valid schema.org; {"foo":1} isn't.
- expect(await check(ORG, [])).toEqual({ passed: true, missing: [] });
- expect(await check(ld('{"foo":1}'), [])).toEqual({
+ // No checks named (another action's fix, #1565 B): the JSON-LD must be
+ // valid schema.org, {"foo":1} isn't, and a page valid all along (the
+ // site's Organization block) isn't fixed by it…
+ expect(await check(ORG, [])).toEqual({ passed: false, missing: ['valid_before'] });
+ const failed = await check(ld('{"foo":1}'), []);
+ expect(failed).toEqual({
passed: false,
missing: ['structured_data_invalid'],
+ sawFailing: true,
+ });
+ // …it passes once a check on this page found it failing.
+ expect(await check(ORG, [], { ...failed, url: PAGE })).toEqual({ passed: true, missing: [] });
+ expect(await check(ORG, [], { ...failed, url: 'https://acme.example/other' })).toEqual({
+ passed: false,
+ missing: ['valid_before'],
});
expect(await check('', ['json-ld-presence', 'json-ld-validity'])).toEqual({
passed: false,
@@ -301,7 +312,7 @@ describe('checkPage', () => {
// A good block beside one that doesn't parse: validity's warn, still open.
const broken = `${ORG}${ld('{"@type":"Product",')}`;
for (const auditChecks of [['json-ld-validity'], []]) {
- expect(await check(broken, auditChecks)).toEqual({
+ expect(await check(broken, auditChecks)).toMatchObject({
passed: false,
missing: ['structured_data_invalid'],
});
@@ -558,6 +569,38 @@ describe('runTaskCheck', () => {
expect((await runTaskCheck(task(), action, { fetch, now })).autoCheck.passed).toBe(true);
});
+ it('passes another action’s structured data fix only after a check found the page failing (#1565 B)', async () => {
+ // F06's brand-entity raised it: none of its checks is a structured data check.
+ db.actions = { targets: [{ id: PAGE, checks: ['brand-entity'] }] };
+ const ORG =
+ '<script type="application/ld+json">{"@context":"https://schema.org","@type":"Organization","name":"Acme"}</script>';
+ const run = (autoCheck, head) =>
+ runTaskCheck(
+ task({
+ task_key: 'fix_structured_data',
+ details: {
+ check: 'auto',
+ url: '/pricing',
+ source: 'template',
+ ...(autoCheck ? { autoCheck } : {}),
+ },
+ }),
+ action,
+ { fetch: fetchOf({ [PAGE]: html('x', head) }), now },
+ );
+ // The site's Organization block was there all along: not fixed by it.
+ const first = await run(null, ORG);
+ expect(first.autoCheck).toMatchObject({ passed: false, missing: ['valid_before'] });
+ expect(first.autoCheck).not.toHaveProperty('sawFailing');
+ // No valid block now: kept as seen failing…
+ const broken = await run(first.autoCheck, '');
+ expect(broken.autoCheck).toMatchObject({ passed: false, sawFailing: true });
+ // …through a read that found it failing again, and then fixed: passed.
+ const still = await run(broken.autoCheck, '');
+ expect(still.autoCheck.sawFailing).toBe(true);
+ expect((await run(still.autoCheck, ORG)).autoCheck).toMatchObject({ passed: true });
+ });
+
it('checks structured data by the checks its page failed, and a crawler fix only from the audit', async () => {
db.actions = { targets: [{ id: PAGE, checks: ['faq-schema'] }] };
const fix = task({ task_key: 'fix_structured_data' });
diff --git a/web/messages/en.json b/web/messages/en.json
index bf0ce197b..49d26f6c6 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -2499,6 +2499,7 @@
"change_not_found": "the new text isn't on the page",
"old_text_still_there": "the text it replaces is still on the page",
"off_site": "the page isn't on the brand's site",
+ "valid_before": "the structured data was valid before the fix. Mark the task done once it's fixed",
"links_not_for_sale": "the page still links products that no longer sell"
},
"taskChecks": {