Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
877f3459f4 | ||
|
|
fa71f9f75d | ||
|
|
06a4e59436 | ||
|
|
08056a8625 | ||
|
|
f11519f877 | ||
|
|
64720ef92e | ||
|
|
6bb960f053 | ||
|
|
5ef67f115f | ||
|
|
b54cfcae39 | ||
|
|
44ba50bd31 | ||
|
|
d90ccdeba0 | ||
|
|
b1bb4279fd | ||
|
|
7093619a0a |
No files matched your search
@@ -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
@@ -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
|
||||
@@ -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
|
||||
|
||||
Generated
+88
-32
@@ -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
@@ -43,7 +43,7 @@
|
||||
"prettier": "3.8.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": ">=24.22.1"
|
||||
},
|
||||
"overrides": {
|
||||
"form-data": ">=4.0.6",
|
||||
|
||||
@@ -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 };
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user