github prompt generator: normalizeGitHubTaskConfig accepts unknown properties, masking config typos

Open Beginner friendly
#45 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
tooling

Research direction

Start in src/prompt-generators/github/config.ts and compare its normalization with src/prompt-generators/bugzilla/config.ts and src/prompt-generators/gitlab/config.ts. Review src/test/schema.test.ts and the schema declarations, then verify that unknown task and search properties and invalid optional search values are rejected consistently with the documented fields.

Written by the indexing model from the issue text.

Description

bug S3

Observed behavior

normalizeGitHubTaskConfig in src/prompt-generators/github/config.ts only validates that promptTemplate and search.repository and search.query are strings. It never calls assertKnownProperties, so any extra (typo'd or stale) property on the task config or on search is silently accepted.

This is inconsistent with the sibling generators:

  • src/prompt-generators/bugzilla/config.ts calls assertKnownProperties on bugzilla.search.
  • src/prompt-generators/gitlab/config.ts calls assertKnownProperties on gitlab.search.
  • The JSON schema in schema/loop-the-loop.schema.json declares additionalProperties: false for both githubTask and githubSearchParams.

Additionally, the github (constructor options) field on the task is not validated at all - a malformed object passed there reaches the SDK constructor.

Expected behavior

normalizeGitHubTaskConfig should reject unknown task-level properties and unknown search properties, matching the schema and the sibling generators. Recommended additions:

  • assertKnownProperties(value, ['github', 'search', 'promptTemplate'], 'github')
  • assertKnownProperties(search, [...], 'github.search') covering every field in GitHubIssueSearchParams (repository, query, sort, order, perPage, maxResults, dryRun, logQuery).
  • Type checks for sort, order, perPage, maxResults, dryRun, logQuery (currently any value is accepted).

Minimal reproduction

import { normalizeGitHubTaskConfig } from 'loop-the-loop/prompt-generators/github/config';

// Silently accepted today (with both 'repositry' typo and 'maxResultz' typo):
normalizeGitHubTaskConfig({
  search: {
    repository: 'octocat/Hello-World',
    query: 'is:open',
    maxResultz: 25,             // typo - silently dropped at runtime
  },
  promptTemplate: 'Review {{id}}',
  notAField: true,              // typo at task level - also silently accepted
});

The same configs are correctly rejected when loaded through the AJV-validated schema (see src/__test__/schema.test.ts), so callers using the CLI loader will see the error, but programmatic callers and anyone bypassing the schema will not.

Suggested fix

Bring github/config.ts into line with bugzilla/config.ts and gitlab/config.ts: add assertKnownProperties for the task and the search params, and add per-field type assertions for the optional search params.

Dominant language
TypeScript
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from joewalker/loop-the-loop

All issues in joewalker/loop-the-loop

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.