gitlab prompt generator: normalizeGitLabTaskConfig accepts unknown task-level properties and an unvalidated 'gitlab' field
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- tooling
Research direction
Start in src/prompt-generators/gitlab/config.ts, reading assertGitLabTaskConfig, normalizeGitLabTaskConfig, and the existing assertGitLabSearchParams validation. Add validation for task-level properties and gitlab constructor options, then add regression coverage for an unknown task key, a non-object gitlab value, and an unknown gitlab property; done means these cases are rejected consistently with the schema.
Written by the indexing model from the issue text.
Description
Observed behavior
normalizeGitLabTaskConfig / assertGitLabTaskConfig in src/prompt-generators/gitlab/config.ts validate gitlab.search thoroughly (via assertKnownProperties and per-field assertions), but the task-level wrapper itself is only partially validated:
- The task config object is never passed through
assertKnownProperties. Typo'd or stale top-level properties (e.g.promptTemplete,searc,gitLab) are silently accepted, with no error or warning. - The optional
gitlabfield, typed asGitLabConstructorOptions({ origin?: string; token?: string; tokenEnv?: string; userAgent?: string }), is not validated at all. Any value, including non-objects (gitlab: 42,gitlab: \"https://gl.test\") or objects with bogus / extra fields (gitlab: { origin: 12345, tokenZ: \"secret\" }), passes the assertion and is handed straight tonew GitLab(this.#task.gitlab)inGitLabPromptGenerator.generate.
This is inconsistent with the schema and with how gitlab.search is validated:
schema/loop-the-loop.schema.jsondeclaresadditionalProperties: falsefor bothgitlabTaskandgitlabConstructorOptions, and requiresorigin/token/tokenEnv/userAgentto be strings.assertGitLabSearchParamsalready usesassertKnownPropertiesto reject unknown search fields. The task level should match.
This is the GitLab-side mirror of issue #45 (the equivalent gap in src/prompt-generators/github/config.ts) and issue #49 (the same shape in src/prompt-generators/bugzilla/config.ts).
Expected behavior
assertGitLabTaskConfig should reject unknown task-level properties and validate the optional gitlab field, so that programmatic callers (and any path that bypasses the AJV-validated CLI schema) get the same protection as schema-validated configs. Recommended additions:
assertKnownProperties(value, ['gitlab', 'search', 'promptTemplate'], 'gitlab').- A new helper to validate
gitlabwhen present: confirm it is a record, callassertKnownProperties(gl, ['origin', 'token', 'tokenEnv', 'userAgent'], 'gitlab.gitlab'), and runassertOptionalStringon each oforigin,token,tokenEnv,userAgent.
Minimal reproduction
import { normalizeGitLabTaskConfig } from 'loop-the-loop/prompt-generators/gitlab/config';
// All three of these are silently accepted today, but the schema rejects them:
normalizeGitLabTaskConfig({
search: { project: 'gitlab-org/gitlab' },
promptTemplate: 'Issue {{id}}',
promptTemplete: 'typo - silently dropped', // unknown task field
});
normalizeGitLabTaskConfig({
search: { project: 'gitlab-org/gitlab' },
promptTemplate: 'Issue {{id}}',
gitlab: 'https://gitlab.example.com', // wrong type - should be object
});
normalizeGitLabTaskConfig({
search: { project: 'gitlab-org/gitlab' },
promptTemplate: 'Issue {{id}}',
gitlab: { origin: 'https://gitlab.example.com', tokenZ: 'typo' }, // typo'd key
});
Running these against dist/prompt-generators/gitlab/config.js confirms all three return objects typed as GitLabTask. The typo'd properties either survive on the returned object (where downstream code never reads them) or get forwarded to the GitLab SDK constructor unchecked.
Suggested fix
Bring gitlab/config.ts into line with the schema and with the level of validation already applied to gitlab.search:
function assertGitLabTaskConfig(value: unknown): asserts value is GitLabTask {
if (!isRecord(value)) {
throw new Error('gitlab task config must be an object');
}
assertKnownProperties(
value,
['gitlab', 'search', 'promptTemplate'],
'gitlab',
);
assertRequiredString(value, 'promptTemplate', 'gitlab.promptTemplate');
if ('gitlab' in value) {
assertGitLabConstructorOptions(value['gitlab']);
}
const search = value['search'];
if (!isRecord(search)) {
throw new Error('gitlab.search must be an object');
}
assertGitLabSearchParams(search);
}
function assertGitLabConstructorOptions(value: unknown): void {
if (!isRecord(value)) {
throw new Error('gitlab.gitlab must be an object');
}
assertKnownProperties(
value,
['origin', 'token', 'tokenEnv', 'userAgent'],
'gitlab.gitlab',
);
assertOptionalString(value, 'origin', 'gitlab.gitlab.origin');
assertOptionalString(value, 'token', 'gitlab.gitlab.token');
assertOptionalString(value, 'tokenEnv', 'gitlab.gitlab.tokenEnv');
assertOptionalString(value, 'userAgent', 'gitlab.gitlab.userAgent');
}
Regression tests should cover: a typo'd task-level key, a non-object gitlab, and a gitlab object with an unknown property.
Severity
S3: the symptom is silent acceptance of broken / stale configuration. Programmatic callers and any path that bypasses the AJV schema check see no error; the misconfigured field is either dropped or forwarded to the SDK, producing surprising downstream behavior.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from joewalker/loop-the-loop
-
bug S4
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
joewalker/loop-the-loop#88 ·
-
Git exec(): child killed by a signal rejects with new Error('') and loses the signal information Openbug S3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
joewalker/loop-the-loop#84 ·
-
bug S3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
joewalker/loop-the-loop#83 ·
-
bug S3
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
joewalker/loop-the-loop#82 ·
-
bug S4
Difficulty 1/5 Under an hour Newbie friendliness 90/100
joewalker/loop-the-loop#79 ·
All issues in joewalker/loop-the-loop
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·