Compare commits

..
Author SHA1 Message Date
spark 877f3459f4 Merge pull request 'chore(runtime): BIT-31730 upgrade Node baseline from 20 to 24.22.1' (#33) from task/BIT-31730-node24-upgrade into main
ai-news-writer-ci / test (push) Successful in 1m20s
2026-10-23 18:00:35 +01:00
CI Runner fa71f9f75d chore(runtime): BIT-31730 upgrade Node baseline from 20 to 24.22.1
ai-news-writer-ci / test (pull_request) Successful in 1m32s
Bump CI (Gitea Actions) node-version and package.json engines to the
Active LTS line, and pull fast-xml-parser/node-cron/pg up to the
versions already allowed by their existing semver ranges. No native
Node addons in the dependency tree and no deprecated API usage found
in src/, so no source changes were needed. Full suite (607 tests),
lint, and npm audit all pass clean on Node 24.22.1.
2026-10-23 17:38:47 +01:00
spark 06a4e59436 Merge pull request 'chore: fix CODEOWNERS to existing Gitea accounts' (#31) from chore/codeowners-fix into main
ai-news-writer-ci / test (push) Successful in 55s
2026-10-22 11:27:37 +01:00
1sonhador 08056a8625 Merge main into chore/codeowners-fix
ai-news-writer-ci / test (pull_request) Successful in 55s
2026-10-22 11:20:09 +01:00
spark f11519f877 Merge pull request 'fix(deps): bump follow-redirects to 1.16.1 (npm audit high)' (#32) from chore/npm-audit-follow-redirects into main
ai-news-writer-ci / test (push) Successful in 50s
2026-10-22 11:19:52 +01:00
1sonhador 64720ef92e fix(deps): bump follow-redirects to 1.16.1 (npm audit high)
ai-news-writer-ci / test (pull_request) Successful in 49s
follow-redirects 1.16.0 has two new high advisories (GHSA-q3jh-wrc6-jgq8,
GHSA-8r9p-f939-6h3c), which fails the npm audit step in CI. Lockfile-only
bump via npm audit fix --package-lock-only.
2026-10-22 11:15:13 +01:00
1sonhador 6bb960f053 chore: limit CODEOWNERS to active Gitea reviewers
ai-news-writer-ci / test (pull_request) Failing after 38s
Only owners that review in practice are listed, so official review
requests from code owners never block merges on protected branches.
2026-10-22 04:45:35 +01:00
1sonhador 5ef67f115f chore: corrige CODEOWNERS para contas existentes no Gitea
ai-news-writer-ci / test (pull_request) Failing after 28s
2026-10-21 17:32:35 +01:00
spark b54cfcae39 Merge pull request 'feat(error-hub): wire errors.bitreport.pt into process diagnostics (BIT-31162)' (#29) from feat/BIT-31162-errors-hub-wiring into main
ai-news-writer-ci / test (push) Successful in 46s
2026-10-19 11:01:04 +01:00
jos-alves 44ba50bd31 fix(lint): remove trailing commas in errorReporting.js
ai-news-writer-ci / test (pull_request) Successful in 47s
CI's lint step was unreachable while the security-audit gate (BIT-31604)
failed first; now that it's fixed, eslint's comma-dangle rule surfaces
on this file. No functional change.

Paperclip-Issue: BIT-31162
2026-10-19 11:00:11 +01:00
jos-alves d90ccdeba0 Merge main (BIT-31604 security-audit fix) into BIT-31162 branch
ai-news-writer-ci / test (pull_request) Failing after 22s
2026-10-19 10:57:34 +01:00
spark b1bb4279fd Merge pull request 'fix(deps): resolve high-severity npm audit findings, scope CI audit to prod deps (BIT-31604)' (#30) from task/BIT-31604-security-audit-fix into main
ai-news-writer-ci / test (push) Successful in 47s
2026-10-19 10:32:52 +01:00
jos-alves 7093619a0a feat(error-hub): wire errors.bitreport.pt reporter into process diagnostics
ai-news-writer-ci / test (pull_request) Failing after 20s
Adds a minimal fire-and-forget client (POST /v1/ingest/events, Bearer
token) and wires it into installProcessDiagnostics() so uncaught
exceptions and unhandled rejections also reach the hub, not just the
local winston logs. No-op when ERROR_REPORTING_TOKEN is unset.

Paperclip-Issue: BIT-31162
2026-10-14 22:17:19 +01:00
8 changed files with 223 additions and 38 deletions

No files matched your search

+6
View File
@@ -83,6 +83,12 @@ QUEUE_MAX_DEPTH=5
# PIPELINE_ALERT_WEBHOOK_URL=
# PIPELINE_ALERT_WEBHOOK_TIMEOUT_MS=4000
# Error hub ingest (errors.bitreport.pt) — vault only; leave empty in Git examples
# ERROR_REPORTING_ENDPOINT=https://errors.bitreport.pt
# ERROR_REPORTING_TOKEN=
ERROR_REPORTING_PROJECT_SLUG=ai-news-writer
ERROR_REPORTING_GITEA_REPO=BitReport.pt/ai-news-writer
# Writing style — optional overrides (defaults come from config/writing-style.example.json)
# WRITING_STYLE_CONFIG_PATH=
# WRITING_TONE=
+4 -4
View File
@@ -2,11 +2,11 @@
# Replace/add owners as needed per repository domain.
# CI and forge metadata
/.gitea/ @tiago-neves @david-santos
/.gitea/workflows/ @tiago-neves @david-santos
/.gitea/ @devops-engineer @founding-engineer
/.gitea/workflows/ @devops-engineer @founding-engineer
# Documentation
/docs/ @david-santos @planner
/docs/ @founding-engineer
# Catch-all
* @david-santos
* @founding-engineer
+1 -1
View File
@@ -45,7 +45,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
node-version: "24"
cache: npm
- name: Install dependencies
+88 -32
View File
@@ -26,7 +26,7 @@
"prettier": "3.8.3"
},
"engines": {
"node": ">=20"
"node": ">=24.22.1"
}
},
"node_modules/@bcoe/v8-coverage": {
@@ -220,9 +220,9 @@
}
},
"node_modules/@nodable/entities": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-2.1.0.tgz",
"integrity": "sha512-nyT7T3nbMyBI/lvr6L5TyWbFJAI9FTgVRakNoBqCD+PmID8DzFrrNdLLtHMwMszOtqZa8PAOV24ZqDnQrhQINA==",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-3.1.0.tgz",
"integrity": "sha512-LsS/DjHr+uDM647Gru/cA8+J3a3HfhttwCKLyuoyN7yXTFCxKBtSgMQBvrW9yNPa2/zDRUNuGPaH5QUFoa4arQ==",
"funding": [
{
"type": "github",
@@ -416,6 +416,18 @@
"node": ">= 8"
}
},
"node_modules/anynum": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/anynum/-/anynum-1.0.1.tgz",
"integrity": "sha512-N6//FLET/tXYNM/F6ABca1oH6fWB+KlTt909Le28WMDBk8oaT4vY17DCrwg2MvmuqUKt3Ni4N5dGJ/EoBgcO6A==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
},
"node_modules/argparse": {
"version": "2.0.1",
"dev": true,
@@ -1138,9 +1150,9 @@
}
},
"node_modules/fast-xml-parser": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.7.2.tgz",
"integrity": "sha512-P7oW7tLbYnhOLQk/Gv7cZgzgMPP/XN03K02/Jy6Y/NHzyIAIpxuZIM/YqAkfiXFPxA2CTm7NtCijK9EDu09u2w==",
"version": "5.11.2",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.11.2.tgz",
"integrity": "sha512-R9iDuNrQYeQut46cn2r2wHKn4HYzVDvDm5J1wW+koZewykv0yuO2HChTYeZtrULyHIDM9cj9TUXloCsueCQUog==",
"funding": [
{
"type": "github",
@@ -1149,15 +1161,32 @@
],
"license": "MIT",
"dependencies": {
"@nodable/entities": "^2.1.0",
"fast-xml-builder": "^1.1.5",
"path-expression-matcher": "^1.5.0",
"strnum": "^2.2.3"
"@nodable/entities": "^3.0.1",
"fast-xml-builder": "^1.2.0",
"is-unsafe": "^2.0.0",
"path-expression-matcher": "^1.6.2",
"strnum": "^2.4.2",
"xml-naming": "^0.3.0"
},
"bin": {
"fxparser": "src/cli/cli.js"
}
},
"node_modules/fast-xml-parser/node_modules/xml-naming": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/xml-naming/-/xml-naming-0.3.0.tgz",
"integrity": "sha512-ghig2TBE/H11aOVgmahA3MhimvkBr6JIYknH/Dhdk10nXwdbIqBJsbfMxpvFPG8bAw77gN29aQWvKpmVoPlvPQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/fastq": {
"version": "1.20.1",
"dev": true,
@@ -1230,7 +1259,9 @@
"license": "MIT"
},
"node_modules/follow-redirects": {
"version": "1.16.0",
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.1.tgz",
"integrity": "sha512-FNvFGzoMLWmE6Yj9spb/zjd7yiNCHiAW9/Tg9CXrQ8wuu32HtlJOwWO11OJafl5FfY3DxTdQ0vj42zU1kvv5jg==",
"funding": [
{
"type": "individual",
@@ -1662,6 +1693,18 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-unsafe": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-unsafe/-/is-unsafe-2.0.2.tgz",
"integrity": "sha512-HgbIHPBH0KHHCcjLfGsCvhtPTVxjaAZlXjwdz7/GQC40SjSe4sfQsar8J5VFo8JOSbarkpV0OLG95bbaNd9aAQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
},
"node_modules/isexe": {
"version": "2.0.0",
"dev": true,
@@ -1877,12 +1920,12 @@
"license": "MIT"
},
"node_modules/node-cron": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/node-cron/-/node-cron-4.2.1.tgz",
"integrity": "sha512-lgimEHPE/QDgFlywTd8yTR61ptugX3Qer29efeyWw2rv259HtGBNn1vZVmp8lB9uo9wC0t/AT4iGqXxia+CJFg==",
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/node-cron/-/node-cron-4.6.0.tgz",
"integrity": "sha512-Si/bzYiKRHOB8/a99T2+SDGN582ONDMSTlJr5oCkT6GtnqPjZ2s10eoQRYkW9ZHwjVxONL+W8Fb+qR0AHMQsdg==",
"license": "ISC",
"engines": {
"node": ">=6.0.0"
"node": ">=20"
}
},
"node_modules/node-domexception": {
@@ -2113,9 +2156,9 @@
}
},
"node_modules/path-expression-matcher": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.5.0.tgz",
"integrity": "sha512-cbrerZV+6rvdQrrD+iGMcZFEiiSrbv9Tfdkvnusy6y0x0GKBXREFg/Y65GhIfm0tnLntThhzCnfKwp1WRjeCyQ==",
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.6.2.tgz",
"integrity": "sha512-enSlaiat05iasnzmgNxRj8reFdj3puY2QpNgP1aPIaVfT6nn9ICuPoFlKHk8EN22HcwewshO+mN2DGbkCEOtqQ==",
"funding": [
{
"type": "github",
@@ -2144,12 +2187,14 @@
}
},
"node_modules/pg": {
"version": "8.20.0",
"version": "8.23.1",
"resolved": "https://registry.npmjs.org/pg/-/pg-8.23.1.tgz",
"integrity": "sha512-aL96AHANtWjPLDOLqnhx+ngp9+UK7ETEU8VJrDCGvsSSi/mGLcWYsS6Herg7lmaBJe4uwrfqsa7gTEFaSizDoQ==",
"license": "MIT",
"dependencies": {
"pg-connection-string": "^2.12.0",
"pg-pool": "^3.13.0",
"pg-protocol": "^1.13.0",
"pg-connection-string": "^2.14.1",
"pg-pool": "^3.14.0",
"pg-protocol": "^1.16.1",
"pg-types": "2.2.0",
"pgpass": "1.0.5"
},
@@ -2157,7 +2202,7 @@
"node": ">= 16.0.0"
},
"optionalDependencies": {
"pg-cloudflare": "^1.3.0"
"pg-cloudflare": "^1.4.1"
},
"peerDependencies": {
"pg-native": ">=3.0.1"
@@ -2169,12 +2214,16 @@
}
},
"node_modules/pg-cloudflare": {
"version": "1.3.0",
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.4.1.tgz",
"integrity": "sha512-6PQbsFWZcp9EmJEwy5cGQ2La+AMWpP46lgbb8X+U/XsHIUweYDNCpeuKck5RxL2MdVFi7krbbEi5nX4Zh7JhrQ==",
"license": "MIT",
"optional": true
},
"node_modules/pg-connection-string": {
"version": "2.12.0",
"version": "2.14.1",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.14.1.tgz",
"integrity": "sha512-qR3kGNPBLpCNtz0evbKA0Y/MRFXwSSdT+pTJvYp/bXTcReZbvX1kzF0IyTc1QnxqF7AZbOeBhNL8R5mYQZV/MA==",
"license": "MIT"
},
"node_modules/pg-int8": {
@@ -2185,14 +2234,18 @@
}
},
"node_modules/pg-pool": {
"version": "3.13.0",
"version": "3.14.0",
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.14.0.tgz",
"integrity": "sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==",
"license": "MIT",
"peerDependencies": {
"pg": ">=8.0"
}
},
"node_modules/pg-protocol": {
"version": "1.13.0",
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.16.1.tgz",
"integrity": "sha512-p9VOFMiHB/ZbJATetbg+99PxssTVSQRnyuPSQ67mN1+1KBOjZaZ83ZQzltnxPhJwSsC3nwVjJ10DVJlerbFzLg==",
"license": "MIT"
},
"node_modules/pg-types": {
@@ -2574,16 +2627,19 @@
}
},
"node_modules/strnum": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.3.tgz",
"integrity": "sha512-oKx6RUCuHfT3oyVjtnrmn19H1SiCqgJSg+54XqURKp5aCMbrXrhLjRN9TjuwMjiYstZ0MzDrHqkGZ5dFTKd+zg==",
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.5.1.tgz",
"integrity": "sha512-UM4nTLWzQiDBseVxUGxN0wJzIk0UU89Qi7pKXz9qISo+lhviJikTuikBsK/oFRlpvYHvSdz0TVoLyQ+sEpYwxA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
"license": "MIT",
"dependencies": {
"anynum": "^1.0.1"
}
},
"node_modules/supports-color": {
"version": "5.5.0",
+1 -1
View File
@@ -43,7 +43,7 @@
"prettier": "3.8.3"
},
"engines": {
"node": ">=20"
"node": ">=24.22.1"
},
"overrides": {
"form-data": ">=4.0.6",
+73
View File
@@ -0,0 +1,73 @@
'use strict';
/**
* Fire-and-forget ingest to errors.bitreport.pt (/v1/ingest/events).
* Enabled when ERROR_REPORTING_TOKEN is set.
*/
const PROJECT_NAME = 'ai-news-writer';
const DEFAULT_PROJECT_SLUG = 'ai-news-writer';
const DEFAULT_GITEA_REPO = 'BitReport.pt/ai-news-writer';
const INGEST_PATH = '/v1/ingest/events';
const MAX_STACK_LEN = 12000;
function ingestBase() {
return (process.env.ERROR_REPORTING_ENDPOINT || 'https://errors.bitreport.pt').replace(/\/$/, '');
}
function ingestToken() {
return (process.env.ERROR_REPORTING_TOKEN || '').trim();
}
function routingMeta() {
const slug = (process.env.ERROR_REPORTING_PROJECT_SLUG || DEFAULT_PROJECT_SLUG).trim() || DEFAULT_PROJECT_SLUG;
const repo = (process.env.ERROR_REPORTING_GITEA_REPO || DEFAULT_GITEA_REPO).trim() || DEFAULT_GITEA_REPO;
return { project_slug: slug, gitea_repo: repo };
}
/**
* Report an Error (or error-like object) to the hub ingest API. Never throws.
* @param {Error} error
* @param {{component?: string}} context
*/
function reportError(error, context = {}) {
const token = ingestToken();
if (!token) {
return;
}
const stack = (error && error.stack) || '';
const stacktrace = stack.length > MAX_STACK_LEN ? `${stack.slice(0, MAX_STACK_LEN)}\n... (truncated)` : stack;
const meta = routingMeta();
const event = {
schema_version: 1,
occurred_at: new Date().toISOString(),
level: 'error',
message: (error && error.message) || String(error),
stacktrace,
context: {
project_name: PROJECT_NAME,
project_slug: meta.project_slug,
gitea_repo: meta.gitea_repo,
component: context.component || 'worker',
environment: process.env.NODE_ENV || 'production',
error_type: (error && error.name) || 'Error'
}
};
const url = `${ingestBase()}${INGEST_PATH}`;
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
'X-Api-Key': token
},
body: JSON.stringify({ events: [event] })
}).catch(() => {
// Never let reporting failures affect the app.
});
}
module.exports = { reportError };
+46
View File
@@ -0,0 +1,46 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert');
const { reportError } = require('./errorReporting');
test('reportError is a no-op without ERROR_REPORTING_TOKEN', async () => {
delete process.env.ERROR_REPORTING_TOKEN;
const originalFetch = global.fetch;
let called = false;
global.fetch = async () => {
called = true;
};
try {
reportError(new Error('boom'));
assert.strictEqual(called, false);
} finally {
global.fetch = originalFetch;
}
});
test('reportError posts a well-formed event to /v1/ingest/events when token is set', async () => {
process.env.ERROR_REPORTING_TOKEN = 'er_test_token';
const originalFetch = global.fetch;
let capturedUrl;
let capturedBody;
global.fetch = async (url, opts) => {
capturedUrl = url;
capturedBody = JSON.parse(opts.body);
return { ok: true };
};
try {
reportError(new Error('boom'), { component: 'worker' });
// reportError fires a promise; let the microtask run.
await new Promise((resolve) => setImmediate(resolve));
assert.ok(capturedUrl.endsWith('/v1/ingest/events'));
const event = capturedBody.events[0];
assert.strictEqual(event.message, 'boom');
assert.strictEqual(event.context.project_slug, 'ai-news-writer');
assert.strictEqual(event.context.gitea_repo, 'BitReport.pt/ai-news-writer');
assert.strictEqual(event.context.component, 'worker');
} finally {
global.fetch = originalFetch;
delete process.env.ERROR_REPORTING_TOKEN;
}
});
+4
View File
@@ -1,6 +1,7 @@
'use strict';
const logger = require('../logger');
const { reportError } = require('../errorReporting');
let _installed = false;
@@ -17,13 +18,16 @@ function installProcessDiagnostics() {
process.on('unhandledRejection', (reason) => {
if (reason instanceof Error) {
logger.error(`unhandledRejection: ${reason.message}`, { stack: reason.stack });
reportError(reason, { component: 'worker' });
return;
}
logger.error(`unhandledRejection: ${String(reason)}`);
reportError(new Error(String(reason)), { component: 'worker' });
});
process.on('uncaughtException', (err) => {
logger.error(`uncaughtException: ${err.message}`, { stack: err.stack });
reportError(err, { component: 'worker' });
process.exit(1);
});
}