Skip to content

Commit e8c0bd6

Browse files
PredictabilityAtScaleCopilot
andcommitted
WEBSITE: Fixed /docs path redirecting to the correct path rather than home
Co-authored-by: Copilot <copilot@github.com>
1 parent ec7bc4b commit e8c0bd6

3 files changed

Lines changed: 366 additions & 100 deletions

File tree

src/validation/validate.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export function validateAsset(
257257
}
258258

259259
for (const [envName, overrides] of Object.entries(asset.environments ?? {})) {
260-
if (asset.cache && !overrides.cache) {
260+
if (asset.cache && (!isRecord(overrides) || !overrides.cache)) {
261261
warnings.push({
262262
code: 'POK045',
263263
message: `Environment "${envName}" does not override cache while prompt-level cache is defined.`,
@@ -268,7 +268,7 @@ export function validateAsset(
268268
}
269269

270270
for (const [tierName, overrides] of Object.entries(asset.tiers ?? {})) {
271-
if (asset.cache && !overrides.cache) {
271+
if (asset.cache && (!isRecord(overrides) || !overrides.cache)) {
272272
warnings.push({
273273
code: 'POK045',
274274
message: `Tier "${tierName}" does not override cache while prompt-level cache is defined.`,
@@ -279,7 +279,7 @@ export function validateAsset(
279279
}
280280

281281
for (const tool of asset.tools ?? []) {
282-
if (typeof tool !== 'string') {
282+
if (isRecord(tool)) {
283283
if (!tool.description) {
284284
warnings.push({
285285
code: 'POK047',
@@ -353,3 +353,7 @@ function findClosestMatch(input: string, candidates: Set<string>): string | unde
353353

354354
return best;
355355
}
356+
357+
function isRecord(value: unknown): value is Record<string, unknown> {
358+
return typeof value === 'object' && value !== null && !Array.isArray(value);
359+
}

tests/validation.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,38 @@ describe('validateAsset', () => {
234234
expect(result.warnings.filter((warning) => warning.code === 'POK047')).toHaveLength(2);
235235
});
236236

237+
it('returns schema errors for malformed override entries instead of throwing', () => {
238+
const result = validateAsset({
239+
id: 'test',
240+
schema_version: 1,
241+
cache: {
242+
openai: { prompt_cache_key: 'test-v1' },
243+
},
244+
environments: {
245+
prod: null,
246+
},
247+
tiers: {
248+
pro: null,
249+
},
250+
sections: { prompt_template: 'Hello' },
251+
} as never);
252+
253+
expect(result.valid).toBe(false);
254+
expect(result.errors.some((error) => error.code === 'POK001')).toBe(true);
255+
});
256+
257+
it('returns schema errors for malformed inline tools instead of throwing', () => {
258+
const result = validateAsset({
259+
id: 'test',
260+
schema_version: 1,
261+
tools: [null],
262+
sections: { prompt_template: 'Hello' },
263+
} as never);
264+
265+
expect(result.valid).toBe(false);
266+
expect(result.errors.some((error) => error.code === 'POK001')).toBe(true);
267+
});
268+
237269
it('does not warn when trim is explicitly false without max_size', () => {
238270
const result = validateAsset({
239271
id: 'test',

0 commit comments

Comments
 (0)