fix(transient): scope bruno- lookup to transient base, not full path (#8273)

This commit is contained in:
Chirag Chandrashekhar
2026-06-18 17:35:27 +05:30
committed by GitHub
parent 36e59e992c
commit 5345cb7b5f

View File

@@ -112,8 +112,9 @@ const getTransientScratchPrefix = () => {
// Check if a path is within the transient directory
const isTransientPath = (filePath) => {
const normalizedFilePath = path.normalize(filePath);
const transientBase = getTransientDirectoryBase();
return filePath.startsWith(transientBase + path.sep) || filePath.startsWith(transientBase);
return normalizedFilePath.startsWith(transientBase + path.sep) || normalizedFilePath === transientBase;
};
const envHasSecrets = (environment = {}) => {
@@ -123,11 +124,14 @@ const envHasSecrets = (environment = {}) => {
};
const findCollectionPathByItemPath = (filePath) => {
const parts = filePath.split(path.sep);
const index = parts.findIndex((part) => part.startsWith('bruno-'));
const normalizedFilePath = path.normalize(filePath);
if (isTransientPath(filePath) && index !== -1) {
const transientDirPath = parts.slice(0, index + 1).join(path.sep);
if (isTransientPath(normalizedFilePath)) {
const transientBase = getTransientDirectoryBase();
const transientDirName = path.relative(transientBase, normalizedFilePath).split(path.sep)[0];
if (!transientDirName) return null;
const transientDirPath = path.join(transientBase, transientDirName);
const metadataPath = path.join(transientDirPath, 'metadata.json');
try {
const metadataContent = fs.readFileSync(metadataPath, 'utf8');
@@ -152,9 +156,6 @@ const findCollectionPathByItemPath = (filePath) => {
// Sort by length descending to find the most specific (deepest) match first
const sortedPaths = allCollectionPaths.sort((a, b) => b.length - a.length);
// Normalize the file path for comparison
const normalizedFilePath = path.normalize(filePath);
for (const collectionPath of sortedPaths) {
const normalizedCollectionPath = path.normalize(collectionPath);
if (normalizedFilePath.startsWith(normalizedCollectionPath + path.sep) || normalizedFilePath === normalizedCollectionPath) {