Skip to content

chore: resolve golangci-lint v2.12.1 goconst findings#172

Merged
Joibel merged 1 commit intomainfrom
fix/golangci-lint-goconst-issues
May 6, 2026
Merged

chore: resolve golangci-lint v2.12.1 goconst findings#172
Joibel merged 1 commit intomainfrom
fix/golangci-lint-goconst-issues

Conversation

@Joibel
Copy link
Copy Markdown
Collaborator

@Joibel Joibel commented May 6, 2026

Summary

  • Resolve all 50 goconst violations reported by golangci-lint v2.12.1 (the version pinned in .github/workflows/ci.yml).
  • Reuse existing constants (KindWorkflow, KindWorkflowTemplate, KindClusterWorkflowTemplate, KindCronWorkflow, OutputFormatJSON, OutputFormatYAML, PhasePending) and introduce new ones for repeated strings: workflow phases (PhaseRunning, PhaseSucceeded, PhaseFailed, PhaseUnknown), template types (templateType*), graph node statuses (nodeStatus*), JSON resource keys (jsonKey*, mimeTypeJSON), the conventional Argo container name (containerMain), and a couple of error/IO strings in the prompts package.
  • Rename three slog field names from "default" to "fallback" so the literal isn't reused with two different meanings (and the namespace use-case gets a proper defaultNamespace constant).

Test plan

  • make lint (with golangci-lint v2.12.1) — 0 issues
  • make test — all packages pass with race detection
  • make vet — clean
  • make fmt — no diffs

Summary by CodeRabbit

  • New Features

    • Added parameter override capability when submitting workflows.
  • Improvements

    • Enhanced error diagnostics for failed workflows with improved pattern detection.
    • Improved log handling with UTF-8 safe truncation to prevent corruption.

Replace 50 repeated string literals across pkg/argo, pkg/prompts,
pkg/resources, and pkg/tools with named constants — using existing
Kind*, Phase*, and OutputFormat* constants where they already existed,
and introducing template-type, node-status, JSON-key, and config
constants where none did. Also rename a couple of slog field names
from "default" to "fallback" to keep their intent clear.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: eb172eb7-a1a3-4899-ba10-04c0e0625a6a

📥 Commits

Reviewing files that changed from the base of the PR and between 4b5ad62 and 3989163.

📒 Files selected for processing (20)
  • pkg/argo/config.go
  • pkg/prompts/why_did_this_fail.go
  • pkg/resources/cluster.go
  • pkg/tools/convert_workflow.go
  • pkg/tools/create_cluster_workflow_template.go
  • pkg/tools/create_cron_workflow.go
  • pkg/tools/create_workflow_template.go
  • pkg/tools/get_workflow_template.go
  • pkg/tools/lint_cluster_workflow_template.go
  • pkg/tools/lint_cron_workflow.go
  • pkg/tools/lint_workflow.go
  • pkg/tools/lint_workflow_template.go
  • pkg/tools/list_workflows.go
  • pkg/tools/logs_workflow.go
  • pkg/tools/render_manifest_graph.go
  • pkg/tools/render_workflow_graph.go
  • pkg/tools/retry_workflow.go
  • pkg/tools/submit_workflow.go
  • pkg/tools/wait_workflow.go
  • pkg/tools/watch_workflow.go

Walkthrough

This pull request standardizes string literals across the codebase by introducing internal constants for configuration values, MIME types, JSON keys, workflow phases, manifest kinds, and node/template types. It also adds error pattern tracking capabilities and UTF-8-safe log truncation to enhance workflow diagnostics.

Changes

Constants and Configuration Standardization

Layer / File(s) Summary
Configuration & Logging
pkg/argo/config.go
Introduces defaultNamespace constant and renames error log field from "default" to "fallback" across three environment-variable parsing paths.
Resource MIME Types & JSON Keys
pkg/resources/cluster.go
Defines constants for MIME type (mimeTypeJSON) and JSON object keys (jsonKeyName, jsonKeyNamespace, jsonKeyCount), then applies them throughout cluster resource endpoints and content builders.
Manifest Kind Validation
pkg/tools/create_cluster_workflow_template.go, pkg/tools/create_cron_workflow.go, pkg/tools/create_workflow_template.go, pkg/tools/lint_cluster_workflow_template.go, pkg/tools/lint_cron_workflow.go, pkg/tools/lint_workflow.go, pkg/tools/lint_workflow_template.go
Replace hardcoded manifest kind strings ("Workflow", "CronWorkflow", "WorkflowTemplate", "ClusterWorkflowTemplate") with corresponding kind constants in validation checks.
Workflow Phase Constants & Utilities
pkg/tools/submit_workflow.go, pkg/tools/retry_workflow.go, pkg/tools/wait_workflow.go, pkg/tools/watch_workflow.go, pkg/tools/list_workflows.go
Expand workflow phase constants (PhasePending, PhaseRunning, PhaseSucceeded, PhaseFailed, PhaseUnknown) and apply them throughout phase assignments and mappings. Add applyParameterOverrides helper to submit handler.
Output Format Constants
pkg/tools/convert_workflow.go
Replace "json" and "yaml" string literals with OutputFormatJSON and OutputFormatYAML constants in manifest serialization.
Template Type Inference
pkg/tools/get_workflow_template.go, pkg/tools/render_manifest_graph.go
Introduce constants for template types (Container, Script, DAG, Steps, Resource, Suspend, HTTP, Plugin, Unknown) and expand determineTemplateType / getTemplateType to return these constants.
Node & Graph Rendering
pkg/tools/render_manifest_graph.go, pkg/tools/render_workflow_graph.go
Add constants for node status class names (nodeStatusSucceeded, nodeStatusFailed, etc.), node types (nodeTypeDAGTask, nodeTypeStep), and default colors; update graph rendering logic to use these constants.
Logging Defaults
pkg/tools/logs_workflow.go
Introduce containerMain constant and apply it as default container reference.
Error Pattern Tracking & Diagnostics
pkg/prompts/why_did_this_fail.go
Add ErrorPattern field to failed node diagnostics; introduce constants for I/O type parameter naming (ioTypeParameter) and image-pull error pattern (errorPatternImagePullBackOff); add truncateStringBytes helper for UTF-8-safe log truncation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A refactoring most grand,
Where strings now bow to constant's command,
With phases, types, and JSON keys made clear,
The code's intent shines ever bright here!
UTF-8 whispers, patterns emerge—
A codebase refined, its quality surge!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main objective of the pull request: resolving golangci-lint goconst findings by replacing string literals with named constants.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/golangci-lint-goconst-issues

Comment @coderabbitai help to get the list of available commands and usage tips.

@Joibel Joibel merged commit 5976a61 into main May 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant