Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/shade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
"clsx": "catalog:",
"cmdk": "1.1.1",
"color": "5.0.3",
"date-fns": "4.1.0",
"lucide-react": "catalog:",
"moment-timezone": "^0.5.48",
"react": "catalog:",
Expand Down
3 changes: 2 additions & 1 deletion ghost/core/core/frontend/services/llms/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ function createLlmsHandler({llmsService, config, settingsCache}) {
const eventDetails = {route: req.path};

logging.error({
system: {event: eventName, ...eventDetails},
event: {name: eventName},
url: {path: req.path},
err
}, `${LLMS_LOG_KEY} ${err.message}`);

Expand Down
35 changes: 10 additions & 25 deletions ghost/core/core/server/services/indexnow.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,8 @@ async function ping(post) {

if (!url || url.endsWith('/404/')) {
logging.warn({
system: {
event: 'indexnow.unresolved_url',
post_id: post.id,
post_slug: post.slug,
url
}
event: {name: 'indexnow.unresolved_url'},
post: {id: post.id, slug: post.slug, url}
}, `${INDEXNOW_LOG_KEY} Skipped ping - post has no resolvable URL`);
return;
}
Expand All @@ -105,11 +101,8 @@ async function ping(post) {
const key = getApiKey();
if (!key) {
logging.warn({
system: {
event: 'indexnow.api_key_missing',
post_id: post.id,
post_slug: post.slug
}
event: {name: 'indexnow.api_key_missing'},
post: {id: post.id, slug: post.slug}
}, `${INDEXNOW_LOG_KEY} API key not available`);
return;
}
Expand Down Expand Up @@ -139,13 +132,9 @@ async function ping(post) {
}

logging.info({
system: {
event: 'indexnow.pinged',
post_id: post.id,
post_slug: post.slug,
url,
status_code: response.statusCode
}
event: {name: 'indexnow.pinged'},
post: {id: post.id, slug: post.slug, url},
http: {response: {status_code: response.statusCode}}
}, `${INDEXNOW_LOG_KEY} Successfully pinged ${url}`);
} catch (err) {
// Log errors but don't throw - IndexNow failures shouldn't disrupt publishing
Expand Down Expand Up @@ -180,13 +169,9 @@ async function ping(post) {
}

logging.warn({
system: {
event: eventName,
post_id: post.id,
post_slug: post.slug,
url,
status_code: err.statusCode ?? null
},
event: {name: eventName},
post: {id: post.id, slug: post.slug, url},
http: {response: {status_code: err.statusCode ?? null}},
err: error
}, `${INDEXNOW_LOG_KEY} ${error.message}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ const reportThemeUploadSizeLimitError = (err, {themeName = null, zip = null} = {
const eventName = `theme_upload.${SIZE_LIMIT_EVENTS_BY_CODE[err.code]}`;
const errorDetails = err.errorDetails || {};
const eventDetails = {
theme_name: themeName,
name: themeName,
entry_name: errorDetails.entryName ?? null,
observed_bytes: errorDetails.observedBytes,
limit_bytes: errorDetails.limitBytes,
compressed_size_bytes: zip?.size ?? null
};

logging.error({
system: {event: eventName, ...eventDetails},
event: {name: eventName},
theme: eventDetails,
err
}, `${THEME_UPLOAD_LOG_KEY} ${err.message}`);

Expand Down
36 changes: 18 additions & 18 deletions ghost/core/test/unit/server/services/indexnow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ describe('IndexNow', function () {
await ping(testPost);

sinon.assert.calledOnce(loggingStub);
assert.equal(loggingStub.args[0][0].system.event, 'indexnow.pinged');
assert.equal(loggingStub.args[0][0].system.status_code, 200);
assert.equal(loggingStub.args[0][0].event.name, 'indexnow.pinged');
assert.equal(loggingStub.args[0][0].http.response.status_code, 200);
});

it('does not ping when the post has no resolvable URL (/404/)', async function () {
Expand All @@ -283,11 +283,11 @@ describe('IndexNow', function () {

assert.equal(pingRequest.isDone(), false);
sinon.assert.calledOnce(loggingStub);
const logged = loggingStub.args[0][0].system;
assert.equal(logged.event, 'indexnow.unresolved_url');
assert.equal(logged.url, 'https://example.com/404/');
assert.equal(logged.post_id, testPost.id);
assert.equal(logged.post_slug, testPost.slug);
const logged = loggingStub.args[0][0];
assert.equal(logged.event.name, 'indexnow.unresolved_url');
assert.equal(logged.post.url, 'https://example.com/404/');
assert.equal(logged.post.id, testPost.id);
assert.equal(logged.post.slug, testPost.slug);
});

it('with default post should not execute ping', async function () {
Expand Down Expand Up @@ -355,7 +355,7 @@ describe('IndexNow', function () {
assert.equal(pingRequest.isDone(), false);
// Should have logged a warning with a structured event
sinon.assert.calledOnce(loggingStub);
assert.equal(loggingStub.args[0][0].system.event, 'indexnow.api_key_missing');
assert.equal(loggingStub.args[0][0].event.name, 'indexnow.api_key_missing');
assert(loggingStub.args[0][1].includes('API key not available'));
});

Expand All @@ -370,8 +370,8 @@ describe('IndexNow', function () {

assert.equal(pingRequest.isDone(), true);
sinon.assert.calledOnce(loggingStub);
assert.equal(loggingStub.args[0][0].system.event, 'indexnow.pinged');
assert.equal(loggingStub.args[0][0].system.status_code, 202);
assert.equal(loggingStub.args[0][0].event.name, 'indexnow.pinged');
assert.equal(loggingStub.args[0][0].http.response.status_code, 202);
});

it('captures && logs errors from 400 requests', async function () {
Expand All @@ -385,8 +385,8 @@ describe('IndexNow', function () {

assert.equal(pingRequest.isDone(), true);
sinon.assert.calledOnce(loggingStub);
assert.equal(loggingStub.args[0][0].system.event, 'indexnow.ping_failed');
assert.equal(loggingStub.args[0][0].system.status_code, 400);
assert.equal(loggingStub.args[0][0].event.name, 'indexnow.ping_failed');
assert.equal(loggingStub.args[0][0].http.response.status_code, 400);
});

it('captures && logs validation errors from 422 requests', async function () {
Expand All @@ -400,8 +400,8 @@ describe('IndexNow', function () {

assert.equal(pingRequest.isDone(), true);
sinon.assert.calledOnce(loggingStub);
assert.equal(loggingStub.args[0][0].system.event, 'indexnow.key_validation_failed');
assert.equal(loggingStub.args[0][0].system.status_code, 422);
assert.equal(loggingStub.args[0][0].event.name, 'indexnow.key_validation_failed');
assert.equal(loggingStub.args[0][0].http.response.status_code, 422);
});

it('should behave correctly when getting a 429', async function () {
Expand All @@ -415,8 +415,8 @@ describe('IndexNow', function () {

assert.equal(pingRequest.isDone(), true);
sinon.assert.calledOnce(loggingStub);
assert.equal(loggingStub.args[0][0].system.event, 'indexnow.rate_limited');
assert.equal(loggingStub.args[0][0].system.status_code, 429);
assert.equal(loggingStub.args[0][0].event.name, 'indexnow.rate_limited');
assert.equal(loggingStub.args[0][0].http.response.status_code, 429);
});

it('logs the real status code for an unexpected 2xx response', async function () {
Expand All @@ -432,8 +432,8 @@ describe('IndexNow', function () {

assert.equal(pingRequest.isDone(), true);
sinon.assert.calledOnce(loggingStub);
assert.equal(loggingStub.args[0][0].system.event, 'indexnow.ping_failed');
assert.equal(loggingStub.args[0][0].system.status_code, 204);
assert.equal(loggingStub.args[0][0].event.name, 'indexnow.ping_failed');
assert.equal(loggingStub.args[0][0].http.response.status_code, 204);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ describe('Theme upload size limit reporter', function () {

sinon.assert.calledOnce(loggingStub);
sinon.assert.calledWith(loggingStub, {
system: {
event: 'theme_upload.entry_too_large',
theme_name: 'large-theme',
event: {name: 'theme_upload.entry_too_large'},
theme: {
name: 'large-theme',
entry_name: 'assets/big.jpg',
observed_bytes: 101,
limit_bytes: 100,
Expand All @@ -60,7 +60,7 @@ describe('Theme upload size limit reporter', function () {
sinon.assert.calledOnceWithExactly(sentryStub, err, {
tags: {source: 'theme_upload.entry_too_large'},
extra: {
theme_name: 'large-theme',
name: 'large-theme',
entry_name: 'assets/big.jpg',
observed_bytes: 101,
limit_bytes: 100,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
},
"devDependencies": {
"@playwright/test": "catalog:",
"@secretlint/secretlint-rule-pattern": "12.3.1",
"@secretlint/secretlint-rule-preset-recommend": "12.3.1",
"@secretlint/secretlint-rule-pattern": "13.0.2",
"@secretlint/secretlint-rule-preset-recommend": "13.0.2",
"eslint": "catalog:",
"eslint-plugin-ghost": "3.5.0",
"eslint-plugin-react": "7.37.5",
Expand All @@ -80,7 +80,7 @@
"lint-staged": "17.0.5",
"nx": "22.7.4",
"rimraf": "6.1.3",
"secretlint": "12.3.1",
"secretlint": "13.0.2",
"semver": "7.7.4",
"typescript": "catalog:",
"vitest": "catalog:"
Expand Down
Loading
Loading