Skip to content

Commit 5da822f

Browse files
Merge pull request #3240 from quadratichq/qa
QA July 17th
2 parents e720954 + 93cdbda commit 5da822f

File tree

39 files changed

+198
-99
lines changed

39 files changed

+198
-99
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ edition = "2024"
1717
description = "Infinite data grid with Python, JavaScript, and SQL built-in"
1818
repository = "https://github.com/quadratichq/quadratic"
1919
license-file = "LICENSE"
20-
version = "0.14.0"
20+
version = "0.14.1"
2121

2222

2323
[profile.release]

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.14.0
1+
0.14.1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quadratic",
3-
"version": "0.14.0",
3+
"version": "0.14.1",
44
"author": {
55
"name": "David Kircos",
66
"email": "david@quadratichq.com",

quadratic-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quadratic-api",
3-
"version": "0.14.0",
3+
"version": "0.14.1",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

quadratic-api/src/ai/handler/ai.handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const handleAIRequest = async (
120120
parsedResponse.usage.source = args.source;
121121
parsedResponse.usage.modelKey = modelKey;
122122
parsedResponse.usage.cost = calculateUsage(parsedResponse.usage);
123-
console.log('[AI.Usage]', parsedResponse.usage);
123+
console.log({ message: 'AI.Usage', usage: parsedResponse.usage });
124124
}
125125

126126
if (debugAndNotInProduction && FINE_TUNE === 'true' && !!parsedResponse) {
@@ -129,7 +129,7 @@ export const handleAIRequest = async (
129129

130130
return parsedResponse;
131131
} catch (error) {
132-
console.error('Error in handleAIRequest: ', modelKey, error);
132+
console.error({ message: 'Error in handleAIRequest', modelKey, error });
133133

134134
Sentry.captureException(error, {
135135
level: 'error',

quadratic-api/src/ai/helpers/modelRouter.helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ ${userTextPrompt}
238238
return MODELS_ROUTER_CONFIGURATION[ai_model];
239239
}
240240
} catch (error) {
241-
console.error('Error in getModelKey: ', error);
241+
console.error({ message: 'Error in getModelKey', error });
242242
}
243243

244244
return DEFAULT_BACKUP_MODEL;

quadratic-api/src/app.ts

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import 'express-async-errors';
66
import fs from 'fs';
77
import helmet from 'helmet';
88
import path from 'path';
9-
import { CORS, NODE_ENV, SENTRY_DSN, VERSION } from './env-vars';
9+
import { CORS, LOG_REQUEST_INFO, NODE_ENV, SENTRY_DSN, VERSION } from './env-vars';
10+
import { logRequestInfo } from './middleware/logRequestInfo';
1011
import internal_router from './routes/internal';
1112
import { ApiError } from './utils/ApiError';
1213

@@ -27,6 +28,11 @@ app.use(helmet());
2728
// set CORS origin from env variable
2829
app.use(cors({ origin: CORS }));
2930

31+
// Request logging middleware for Datadog
32+
if (LOG_REQUEST_INFO) {
33+
app.use(logRequestInfo);
34+
}
35+
3036
// Health-check
3137
app.get('/', (req, res) => {
3238
res.status(200).json({ message: 'OK' });
@@ -39,36 +45,39 @@ app.get('/health', (req, res) => {
3945
// Internal routes
4046
app.use('/v0/internal', internal_router);
4147

42-
// Register all our dynamic routes, then regsiter the error middleware last of all
48+
// Register all our dynamic routes, then register the error middleware last of all
4349
registerRoutes().then(() => {
4450
// Error-logging middleware
45-
app.use((err: any, req: Request, res: Response, next: NextFunction) => {
51+
app.use((error: any, req: Request, res: Response, next: NextFunction) => {
4652
if (NODE_ENV !== 'test') {
47-
if (err.status >= 500) {
48-
if (NODE_ENV === 'production') console.error(`[${new Date().toISOString()}]`, err);
49-
else console.log(`[${new Date().toISOString()}]`, err);
53+
if (error.status >= 500) {
54+
if (NODE_ENV === 'production') {
55+
console.error({ time: new Date().toISOString(), error });
56+
} else {
57+
console.log({ time: new Date().toISOString(), error });
58+
}
5059
}
5160
}
52-
next(err);
61+
next(error);
5362
});
5463

5564
// Error-handling middleware
56-
app.use((err: any, req: Request, res: Response, next: NextFunction) => {
65+
app.use((error: any, req: Request, res: Response, next: NextFunction) => {
5766
// Check if headers have already been sent
5867
if (res.headersSent) {
59-
return next(err);
68+
return next(error);
6069
}
6170

6271
// Application-specific error handling
63-
if (err instanceof ApiError) {
64-
res.status(err.status).json({ error: { message: err.message, ...(err.meta ? { meta: err.meta } : {}) } });
72+
if (error instanceof ApiError) {
73+
res.status(error.status).json({ error: { message: error.message, ...(error.meta ? { meta: error.meta } : {}) } });
6574
} else {
66-
console.error(err);
75+
console.error({ error });
6776

6877
// Generic error handling
69-
res.status(err.status || 500).json({
78+
res.status(error.status || 500).json({
7079
error: {
71-
message: err.message,
80+
message: error.message,
7281
},
7382
});
7483
}
@@ -100,7 +109,7 @@ async function registerRoutes() {
100109
if (httpMethodIndex === -1) httpMethodIndex = segments.indexOf('DELETE');
101110

102111
if (httpMethodIndex === -1) {
103-
console.error('File route is malformed. It needs an HTTP method: %s', file);
112+
console.error({ message: 'File route is malformed. It needs an HTTP method', file });
104113
} else {
105114
const httpMethod = segments[httpMethodIndex].toLowerCase() as 'get' | 'post' | 'put' | 'patch' | 'delete';
106115
const routeSegments = segments.slice(0, httpMethodIndex);
@@ -112,14 +121,17 @@ async function registerRoutes() {
112121
app[httpMethod](expressRoute, ...callbacks);
113122
registeredRoutes.push(httpMethod.toUpperCase() + ' ' + expressRoute);
114123
} catch (err) {
115-
console.error(`Failed to register route: ${expressRoute}`, err);
124+
console.error({ message: 'Failed to register route', expressRoute, error: err });
116125
}
117126
}
118127
}
119128

120129
// Keep around for debugging
121130
// if (NODE_ENV !== 'production' && NODE_ENV !== 'test') {
122-
// console.log(`Dynamically registered routes: ${registeredRoutes.map((route) => `\n ${route}`).join('')}`);
131+
// console.log({
132+
// message: 'Dynamically registered routes',
133+
// routes: registeredRoutes.map((route) => `\n ${route}`).join(''),
134+
// });
123135
// }
124136
}
125137

quadratic-api/src/auth/auth0.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const getUsersFromAuth0 = async (users: { id: number; auth0Id: string }[]
8888

8989
// If missing or incomplete, fallback to direct lookup
9090
if (!auth0User || !auth0User.email) {
91-
console.log('Fallback to direct lookup for', auth0Id);
91+
console.log({ message: 'Fallback to direct lookup for', auth0Id });
9292
try {
9393
auth0User = await getAuth0().getUser({ id: auth0Id });
9494
} catch (err) {
@@ -104,7 +104,7 @@ export const getUsersFromAuth0 = async (users: { id: number; auth0Id: string }[]
104104

105105
// If we're missing data we expect, log it to Sentry and throw
106106
if (!auth0User || !auth0User.email) {
107-
console.log('Failed to retrieve all user info from Auth0', auth0Id);
107+
console.log({ message: 'Failed to retrieve all user info from Auth0', auth0Id });
108108
Sentry.captureException({
109109
message: 'Auth0 user returned without `email`',
110110
level: 'error',

quadratic-api/src/auth/ory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export const getUsersFromOry = async (users: { id: number; auth0Id: string }[]):
3333

3434
try {
3535
identities = (await sdk.listIdentities({ ids })).data;
36-
} catch (e) {
37-
console.error(e);
36+
} catch (error) {
37+
console.error({ message: 'Error in getUsersFromOry', error });
3838
return {};
3939
}
4040

@@ -77,8 +77,8 @@ export const getUsersFromOryByEmail = async (email: string): Promise<ByEmailUser
7777

7878
try {
7979
identities = (await sdk.listIdentities({ credentialsIdentifier: email })).data;
80-
} catch (e) {
81-
console.error(e);
80+
} catch (error) {
81+
console.error({ message: 'Error in getUsersFromOryByEmail', error });
8282
return [];
8383
}
8484

quadratic-api/src/data/connections.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ try {
2525
isDemo: true,
2626
});
2727
} catch (error) {
28-
console.log('`CONNECTION_DEMO` env var is missing or malformed. No demo connection will be available.', error);
28+
console.log({
29+
message: '`CONNECTION_DEMO` env var is missing or malformed. No demo connection will be available.',
30+
error,
31+
});
2932
}

0 commit comments

Comments
 (0)