[Duplicate Code] Shared JSON-object validation helper
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- tooling
Research direction
The duplicated requireObject(value, label) helper appears in src/cloud-hypervisor/artifact-manifest.ts (lines 37-54) and src/nvx/outcome.ts (lines 137-154). Compare the two copies, then move one shared version into a new common validation module and import it from both call sites. Done means a single definition remains, both files use the import, and the existing tests for those modules still pass.
Written by the indexing model from the issue text.
Description
Duplicate Code Opportunity
Summary
- Pattern: Two modules independently implement the same
requireObject(value, label)guard that checks for a non-null plain object and throws an identical error message. - Locations:
src/cloud-hypervisor/artifact-manifest.tslines 37-54;src/nvx/outcome.tslines 137-154. - Impact: This is a small but repeated validation helper in configuration/persistence code. A shared utility would centralize object-shape validation and keep error text consistent.
Evidence
src/cloud-hypervisor/artifact-manifest.ts: lines 37-54src/nvx/outcome.ts: lines 137-154
// src/cloud-hypervisor/artifact-manifest.ts
function requireObject(value: unknown, label: string): Record<string, unknown> {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
throw new Error(`${label} must be a JSON object`);
// src/nvx/outcome.ts
function requireObject(value: unknown, label: string): Record<string, unknown> {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
throw new Error(`${label} must be a JSON object`);
Suggested Refactoring
Extract a shared requireObject(...) helper into a common validation module and reuse it across both persistence/manifest parsers.
Affected Files
src/cloud-hypervisor/artifact-manifest.ts— lines 37-54src/nvx/outcome.ts— lines 137-154
Effort Estimate
Low
Detected by Duplicate Code Detector workflow. Run date: 2026-10-15
Generated by Duplicate Code Detector · copilot · gpt54mini · 3.44 AIC · ⊞ 29.7K · ◷
- expires on Nov 14, 2026, 9:51 PM UTC
- Dominant language
- TypeScript
- Stars
- 149
- Forks
- 77
- Avg merge
- 4h 20m
- Merged PRs (30d)
- 436
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
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 github/gh-aw-firewall
-
agentic-workflows automated dependencies
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/gh-aw-firewall#3837 ·
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 4/5 1-2 days Newbie friendliness 35/100
github/gh-aw-firewall#10315 ·
Maintainers usually reply within 1 day
-
Router: port the routing core and CLI to Go (built and tested, not shipped)Possibly taken @rabeckett claimed this today. Openenhancement refactoring
Difficulty 5/5 Over a week Newbie friendliness 1/100
github/gh-aw-firewall#10312 ·
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
github/gh-aw-firewall#10309 ·
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 3/5 1-2 days Newbie friendliness 35/100
github/gh-aw-firewall#10308 ·
Maintainers usually reply within 1 day
All issues in github/gh-aw-firewall
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
equinor/prisma-decision-web#919 ·
Maintainers usually reply within 1 day
-
[DC] OneLogin sync imports a partial user list when an API request failsPossibly taken @RaphaelFakhri claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
bitwarden/directory-connector#1276 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
home-assistant/installer#324 ·
Maintainers usually reply within 1 day
-
Mondriaan
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
knaw-huc/textannoviz#733 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day