Skip to content

Commit ad7390a

Browse files
authored
Merge pull request #77 from sigmacomputing/testing-patches
Testing patches
2 parents a8b47e3 + 9aa7ffc commit ad7390a

22 files changed

Lines changed: 6957 additions & 858 deletions

File tree

embedding_qs_series_2_api_use_cases/package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

recipe-portal/app/api/call/route.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function getCachedToken(): { token: string; clientId: string } | null {
5555

5656
export async function POST(request: Request) {
5757
try {
58-
const { endpoint, method, parameters = {}, requestBody } = await request.json();
58+
const { endpoint, method, parameters = {}, requestBody, baseURL: providedBaseURL } = await request.json();
5959

6060
if (!endpoint) {
6161
return NextResponse.json(
@@ -76,9 +76,11 @@ export async function POST(request: Request) {
7676
);
7777
}
7878

79-
// Build the full URL
80-
const baseURL = process.env.SIGMA_BASE_URL || 'https://aws-api.sigmacomputing.com/v2';
79+
// Build the full URL - use provided baseURL to prevent race conditions, fallback to environment/default
80+
const baseURL = providedBaseURL || process.env.SIGMA_BASE_URL || 'https://aws-api.sigmacomputing.com/v2';
8181
let url = `${baseURL}${endpoint}`;
82+
83+
console.log(`API Call: ${method} ${url} (baseURL from auth config: ${baseURL})`);
8284

8385
// Add query parameters
8486
if (parameters.query && Object.keys(parameters.query).length > 0) {

recipe-portal/app/api/code/route.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,26 @@ export async function GET(request: Request) {
77
const { searchParams } = new URL(request.url);
88
const filePath = searchParams.get('path');
99

10+
console.log('=== CODE API DEBUG ===');
11+
console.log('Received filePath:', filePath);
12+
console.log('Process CWD:', process.cwd());
13+
1014
if (!filePath) {
1115
return NextResponse.json(
1216
{ error: 'File path is required' },
1317
{ status: 400 }
1418
);
1519
}
1620

21+
// Force the file path to be relative to our current working directory
22+
const relativePath = filePath.replace(/^.*recipes\//, 'recipes/');
23+
const correctedPath = path.join(process.cwd(), relativePath);
24+
25+
console.log('Corrected path:', correctedPath);
26+
1727
// Security check: ensure the file is within the recipes directory
1828
const recipesPath = path.join(process.cwd(), 'recipes');
19-
const resolvedPath = path.resolve(filePath);
29+
const resolvedPath = path.resolve(correctedPath);
2030
const resolvedRecipesPath = path.resolve(recipesPath);
2131

2232
if (!resolvedPath.startsWith(resolvedRecipesPath)) {

recipe-portal/app/api/download-stream/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ envLines.forEach(line => {
165165
// Token caching
166166
function getTokenCacheFile(clientId: string) {
167167
const configHash = clientId ? clientId.substring(0, 8) : "default";
168-
return path.join(os.tmpdir(), `sigma-portal-token-${configHash}.json`);
168+
return path.join(os.tmpdir(), "sigma-portal-token-" + configHash + ".json");
169169
}
170170
171171
function getCachedToken(): { token: string; clientId: string } | null {

0 commit comments

Comments
 (0)