Skip to content

[duplicate-code] Duplicate Code: Identical timeout parsers in tools_parser.go #67004

Description

@github-actions

🔍 Duplicate Code Detected: Identical TemplatableInt32 timeout parsers

Analysis of commit 8c2337a

Assignee: @copilot

Summary

parseTimeoutTool and parseStartupTimeoutTool in pkg/workflow/tools_parser.go have byte-for-byte identical bodies (24 normalized lines each). They differ only in name and doc comment.

Duplication Details

Pattern: Identical numeric/expression type-switch parser

  • Severity: Medium
  • Occurrences: 2
  • Locations:
    • pkg/workflow/tools_parser.go (lines 591-616, parseTimeoutTool)
    • pkg/workflow/tools_parser.go (lines 620-645, parseStartupTimeoutTool)
  • Code Sample:
    func parseTimeoutTool(val any) *TemplatableInt32 {
        switch v := val.(type) {
        case int:
            t := TemplatableInt32(strconv.Itoa(v))
            return &t
        case int64:
            t := TemplatableInt32(strconv.FormatInt(v, 10))
            return &t
        // ... uint, uint64, float64, string(expression) cases identical ...
        }
        return nil
    }

Impact Analysis

  • Maintainability: Any change to accepted types/expression handling must be made in two places.
  • Bug Risk: High chance the two copies drift out of sync (inconsistent timeout parsing).
  • Code Bloat: ~26 duplicated lines in a single file.

Refactoring Recommendations

  1. Collapse into one helper
    • Keep a single parseTemplatableInt32(val any) *TemplatableInt32 and have both call sites use it (drop one function, or make parseStartupTimeoutTool delegate to parseTimeoutTool).
    • Estimated effort: ~15 min, low complexity.
    • Benefits: single source of truth, no drift.

Implementation Checklist

  • Replace one function body with a delegating call (or remove it and update callers)
  • Run make fmt and make test-unit
  • Verify no functionality broken
Analysis Metadata
  • Analyzed Area: pkg/ non-test .go files
  • Detection Method: normalized function-body hashing + manual verification
  • Commit: 8c2337a

Generated by 🔍 Duplicate Code Detector · pi · opus48 · 52.6 AIC · ⌖ 40.5 AIC · ⊞ 1.5K · ◷

  • expires on Oct 10, 2026, 1:57 PM UTC-08:00

Activity

  1. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 12.6 AIC · ⌖ 9.93 AIC · ⊞ 13.5K · ◷

  2. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 21.3 AIC · ⌖ 12.1 AIC · ⊞ 13.3K · ◷

  3. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 31 AIC · ⌖ 9.03 AIC · ⊞ 13.3K · ◷

  4. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    Caution

    agentic threat detected
    Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

    Details

    Potential security threats were detected in the agent output.

    Review the workflow run logs for details.

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 24.5 AIC · ⌖ 16.4 AIC · ⊞ 13.3K · ◷

  5. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 12.4 AIC · ⌖ 8.06 AIC · ⊞ 12.6K · ◷

  6. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 10.4 AIC · ⌖ 9.67 AIC · ⊞ 12.6K · ◷

  7. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 12.3 AIC · ⌖ 10.6 AIC · ⊞ 12.6K · ◷

  8. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 10.8 AIC · ⌖ 7.92 AIC · ⊞ 12.6K · ◷

  9. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    Ive identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 28.7 AIC · ⌖ 6.88 AIC · ⊞ 12.6K · ◷

  10. github-actions commented on Oct 10, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-10-10T21:57:41.351Z.

    Closed by Workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions