{"record":{"id":"7837e2b3d44b65f0","repo":"medusajs/medusa","slug":"file-entry-name-in-policies-directory-does-not","errorCode":null,"errorMessage":"File ${entry.name} in policies directory does not export any policies","messagePattern":"File (.+?) in policies directory does not export any policies","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/utils/src/policies/discover-policies.ts","lineNumber":63,"sourceCode":"            return\n          }\n\n          if (\n            excludedExtensions.some((ext) => entry.name.endsWith(ext)) ||\n            excludedFiles.includes(entry.name)\n          ) {\n            return\n          }\n\n          // Import the file - this will execute definePolicies() calls\n          const fileExports = await dynamicImport(join(scanDir, entry.name))\n\n          // Validate that at least one export is a policy\n          const values = Object.values(fileExports)\n          const hasPolicies = values.some((value) => isPolicyExport(value))\n\n          if (!hasPolicies) {\n            console.warn(\n              `File ${entry.name} in policies directory does not export any policies`\n            )\n          }\n        })\n      )\n    })\n  )\n}\n","sourceCodeStart":45,"sourceCodeEnd":72,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/policies/discover-policies.ts#L45-L72","documentation":"The policies loader scans a policies directory, imports each file, and checks whether at least one export is a valid policy (a function or object matching the policy shape). If none qualifies, the file contributes nothing and a console.warn is printed; the rest of policy loading continues.","triggerScenarios":"A file in the scanned policies directory exporting only helpers, types, or objects that fail isPolicyExport — e.g. exporting a plain config object, an empty object, or non-function constants.","commonSituations":"Placing shared utils or barrel (index re-export) files inside the policies folder; refactoring a policy into named exports that no longer match the expected policy shape; leftover scaffolding files.","solutions":["Ensure the file exports at least one valid policy (the expected function/object shape per isPolicyExport)","Move helper/barrel files out of the policies directory, or prefix them so the loader skips them","Remove dead scaffolding files from the policies folder"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const exports = await import(filePath)\nif (!Object.values(exports).some(isPolicyExport)) {\n  console.warn(`${filePath} has no policies; move it out of the policies dir`)\n}","typeGuard":"const isPolicyFile = (exports: Record<string, unknown>) =>\n  Object.values(exports).some((v) => typeof v === \"function\")","tryCatchPattern":null,"preventionTips":["Only put policy modules in the policies directory","Keep barrels/helpers elsewhere"],"tags":["policies","loader","export-validation"],"backgroundTag":"invalid-export-shape","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}