[Duplicate Code] Repeated filtered model-alias assembly in proxy server
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript
Research direction
Start in containers/api-proxy/server.js around lines 167-194 and compare buildModelsJson() with writeModelsJson(). Extract the shared configured-provider and filtered-alias assembly, then ensure both callers use it without changing model metadata behavior. Done means the duplicated filtering block is removed and both functions remain aligned.
Written by the indexing model from the issue text.
Description
Duplicate Code Opportunity
Summary
- Pattern:
containers/api-proxy/server.jsbuilds the sameconfiguredProviders+filteredAliasesstructure twice: once forbuildModelsJson()and again forwriteModelsJson(). - Locations:
containers/api-proxy/server.jslines 167-194. - Impact: Removes one duplicated alias-filtering block from the security-sensitive proxy startup/management path and keeps model metadata generation consistent.
Evidence
Block A — buildModelsJson()
function buildModelsJson() {
const configuredProviders = getConfiguredModelCacheKeys();
const filteredAliases = MODEL_ALIASES ? {
models: filterResolvableAliases(
MODEL_ALIASES.models,
filterAvailableModelsToConfiguredProviders(cachedModels, configuredProviders),
configuredProviders,
),
} : null;
return _buildModelsJson(registeredAdapters, cachedModels, filteredAliases, getRuntimeCatalogSnapshot());
}
Block B — writeModelsJson()
function writeModelsJson(logDir) {
const configuredProviders = getConfiguredModelCacheKeys();
const filteredAliases = MODEL_ALIASES ? {
models: filterResolvableAliases(
MODEL_ALIASES.models,
filterAvailableModelsToConfiguredProviders(cachedModels, configuredProviders),
configuredProviders,
),
} : null;
const modelsJson = _buildModelsJson(
registeredAdapters,
cachedModels,
filteredAliases,
getRuntimeCatalogSnapshot(),
);
return _writeModelsJson(registeredAdapters, cachedModels, filteredAliases, logDir, modelsJson);
}
Suggested Refactoring
Extract a shared helper that returns the filtered alias snapshot once, then have both callers reuse it. For example:
getFilteredModelAliases()for theconfiguredProviders/filteredAliasesassemblybuildModelsSnapshot()to produce the shared JSON payload used by bothbuildModelsJson()andwriteModelsJson()
This keeps alias filtering and model snapshot generation aligned and reduces the chance of drift if the filtering rules change.
Affected Files
containers/api-proxy/server.js— lines 167-194
Effort Estimate
Low
Detected by Duplicate Code Detector workflow. Run date: 2026-09-20
Generated by Duplicate Code Detector · copilot · gpt50mini · 5.79 AIC · ⊞ 21K · ◷
- expires on Oct 20, 2026, 9:42 PM UTC
- Dominant language
- TypeScript
- Stars
- 145
- Forks
- 63
- Avg merge
- 5h 55m
- Merged PRs (30d)
- 226
Contributor 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 ·
-
agentic-workflows cascade-rollup
Difficulty 4/5 3-5 days Newbie friendliness 25/100
github/gh-aw-firewall#8813 ·
-
agentic-workflows cascade-suspected
Difficulty 3/5 1-2 days Newbie friendliness 35/100
github/gh-aw-firewall#8812 ·
-
agentic-workflows cascade-suspected
Difficulty 3/5 1-2 days Newbie friendliness 42/100
github/gh-aw-firewall#8811 ·
-
agentic-workflows cascade-suspected
Difficulty 3/5 1-2 days Newbie friendliness 35/100
github/gh-aw-firewall#8810 ·
All issues in github/gh-aw-firewall
Similar issues
-
comp/dashboard P3 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NousResearch/hermes-agent#117722 ·
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·