Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .bumpy/fix-md5-uppercase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
varlock: patch
---

Accept uppercase hex for @type=md5
6 changes: 5 additions & 1 deletion packages/varlock/src/env-graph/lib/data-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,12 +608,16 @@ const UuidDataType = createEnvGraphDataType({
},
});

const MD5_REGEX = /^[a-f0-9]{32}$/;
const MD5_REGEX = /^[a-f0-9]{32}$/i;
const Md5DataType = createEnvGraphDataType({
name: 'md5',
typeDescription: 'MD5 hash string',
// A deterministic, unique, valid 32-hex string derived from the seed.
generatePlaceholder: (seed) => hexFromSeed(seed).slice(0, 32),
coerce(rawVal) {
// Accept uppercase hex (common from tools) and normalize like typical hash handling
return coerceToString(rawVal).toLowerCase();
},
validate(val) {
const result = MD5_REGEX.test(val);
if (result) return true;
Expand Down
20 changes: 20 additions & 0 deletions packages/varlock/src/env-graph/test/data-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,26 @@ describe('url data type - path values', () => {
});
});

describe('md5 data type', () => {
it('accepts lowercase md5', async () => {
const g = await loadAndResolve(outdent`
# @type=md5
H=d41d8cd98f00b204e9800998ecf8427e
`);
expect(g.configSchema.H.isValid).toBe(true);
expect(g.configSchema.H.resolvedValue).toBe('d41d8cd98f00b204e9800998ecf8427e');
});

it('accepts uppercase md5 and normalizes to lowercase', async () => {
const g = await loadAndResolve(outdent`
# @type=md5
H=D41D8CD98F00B204E9800998ECF8427E
`);
expect(g.configSchema.H.isValid).toBe(true);
expect(g.configSchema.H.resolvedValue).toBe('d41d8cd98f00b204e9800998ecf8427e');
});
});

describe('string data type - matches option', () => {
it('accepts string matching regex literal', async () => {
const g = await loadAndResolve(outdent`
Expand Down
Loading