Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Duplicate Code] Shared JSON-object validation helper

Closed Beginner friendly
#10,040 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@lpcox is already working on this.

Since Oct 16, 2026.

  • #10062 by @copilot-swe-agent — merged

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

code-quality refactoring

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.ts lines 37-54; src/nvx/outcome.ts lines 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-54
  • src/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-54
  • src/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

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 github/gh-aw-firewall

All issues in github/gh-aw-firewall

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.