Improve prompt validation with new static warnings for inputs, cache, provider, and tools#11
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f41130070
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| for (const [envName, overrides] of Object.entries(asset.environments ?? {})) { | ||
| if (asset.cache && !overrides.cache) { |
There was a problem hiding this comment.
Guard override entries before reading
cache
validateAsset now dereferences overrides.cache without checking that each environments entry is an object. If a caller passes malformed input (for example { environments: { prod: null } }), safeParse correctly identifies schema issues, but this line throws a TypeError before validation results are returned. That turns a recoverable validation failure into a hard crash; the same pattern appears in the tier loop as well.
Useful? React with 👍 / 👎.
|
|
||
| for (const tool of asset.tools ?? []) { | ||
| if (typeof tool !== 'string') { | ||
| if (!tool.description) { |
There was a problem hiding this comment.
Guard inline tool checks against non-object values
The new inline-tool warning path assumes every non-string tool entry is an object and directly reads tool.description. For malformed assets like { tools: [null] }, validation now throws (Cannot read properties of null) instead of returning POK001 schema errors. Since this function already calls safeParse, it should tolerate bad shapes and keep reporting structured validation output.
Useful? React with 👍 / 👎.
Motivation
provider_optionsto known keys and update docs to enumerate the new warning codes.Description
POK046to warn when a template uses variables butcontext.inputsis not declared and suggest declaringcontext.inputsfor policy validation via thevalidateAssetcheck.POK040andPOK041to flag context inputs that look unbounded (common names withoutmax_size) and inputs missing hardening validators, using aRISKY_UNBOUNDED_INPUT_NAMESheuristic.POK042(missing provider cache config),POK043(conflicting Gemini/Google cached_content),POK044(provider configured withoutmodel), andPOK045(environment/tier cache overrides missing).POK047whendescriptionorinput_schemaare missing for inline tool definitions.docs/validation.mdto document all new codes and addprovider_optionsto known front-matter keys.tests/validation.test.tsto cover the new warnings and behaviors.Testing
tests/validation.test.tscoveringPOK046,POK040/POK041,POK042/POK044,POK043, andPOK047scenarios.npm test.Codex Task