Skip to content

Conversation

@moshloop
Copy link
Member

@moshloop moshloop commented Dec 14, 2025

Summary by CodeRabbit

Release Notes

  • Refactor
    • Restructured JSON processing pipeline with improved modularity and error handling
    • Enhanced template parameter handling to support broader data types
    • Strengthened error messages with contextual metadata during processing stages

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 14, 2025

Walkthrough

Azure DevOps client changes TemplateParameters field type from map[string]string to map[string]any in Pipeline and Run structs, with corresponding value-to-string conversions in GetLabels, GetTags, and GetID methods. JSON processor refactors Extract method into sequential pipeline stages: transform, property parsing, item extraction, and post-processing, with enhanced error handling and debug logging.

Changes

Cohort / File(s) Summary
Azure DevOps Client Type Update
scrapers/azure/devops/client.go
Changed Pipeline.TemplateParameters and Run.TemplateParameters from map[string]string to map[string]any. Updated GetLabels, GetTags, and GetID to convert values to strings via fmt.Sprintf("%v", v) for proper handling of any-typed values.
JSON Processor Pipeline Refactoring
scrapers/processors/json.go
Restructured Extract method from inline processing to multi-stage pipeline: transform (applies transformation script), parseProperties (evaluates and templates scraper properties), extractItems (expands per-input Items), and postProcess (applies masks, sets health defaults, resolves locations/aliases). Added granular error handling with format/source metadata and conditional debug logging.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Pr/fix azure' is extremely vague and does not clearly describe the main changes in the pull request. Use a more descriptive title that summarizes the primary changes, such as 'Support template parameter values as any type in Azure DevOps scraper and refactor JSON processor pipeline' or 'Update Azure DevOps template parameters to support dynamic types'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pr/fix-azure

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scrapers/azure/devops/client.go (1)

60-74: Fix format specifier for any-typed value.

Line 68 uses %s for the value, but v is now any type. This will cause incorrect formatting for non-string values.

Apply this diff:

 		for k, v := range p.TemplateParameters {
-			params = append(params, fmt.Sprintf("%s=%s", k, v))
+			params = append(params, fmt.Sprintf("%s=%v", k, v))
 		}
🧹 Nitpick comments (1)
scrapers/processors/json.go (1)

407-437: Consider extracting duplicate error message construction.

The error message construction logic for JSON parsing failures is duplicated in both branches (lines 412-419 and 425-435).

Consider extracting to a helper:

func formatJSONParseError(err error, input v1.ScrapeResult) string {
	s := "failed to parse json"
	if input.Format != "" {
		s += fmt.Sprintf(" format=%s", input.Format)
	}
	if input.Source != "" {
		s += fmt.Sprintf(" source=%s", input.Source)
	}
	return s
}

Then use it:

 		parsedConfig, err = oj.ParseString(v)
 		if err != nil {
-			s := "failed to parse json"
-			if input.Format != "" {
-				s += fmt.Sprintf(" format=%s", input.Format)
-			}
-			if input.Source != "" {
-				s += fmt.Sprintf(" source=%s", input.Source)
-			}
-			return nil, fmt.Errorf("%s: %v\n%s", s, err, v)
+			return nil, fmt.Errorf("%s: %v\n%s", formatJSONParseError(err, input), err, v)
 		}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7952468 and 70b77ed.

📒 Files selected for processing (2)
  • scrapers/azure/devops/client.go (3 hunks)
  • scrapers/processors/json.go (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
scrapers/processors/json.go (7)
api/v1/interface.go (3)
  • ScrapeResult (598-669)
  • ScrapeResults (348-348)
  • ChangeResult (77-105)
api/v1/json_types.go (1)
  • JSON (16-16)
api/v1/data.go (2)
  • Properties (26-26)
  • Property (29-39)
api/context.go (1)
  • ScrapeContext (16-27)
api/v1/common.go (4)
  • Template (409-415)
  • BaseScraper (240-255)
  • Transform (139-153)
  • Script (30-35)
scrapers/azure/devops/client.go (1)
  • Link (30-32)
scrapers/processors/script.go (1)
  • RunScript (10-27)
🪛 GitHub Actions: Build
scrapers/processors/json.go

[error] 12-12: No required module provides package github.com/flanksource/clicky; to add it: go get github.com/flanksource/clicky

🪛 GitHub Actions: Lint
scrapers/processors/json.go

[error] 12-12: could not import github.com/flanksource/clicky (scrapers/processors/json.go:12:2: no required module provides package github.com/flanksource/clicky; to add it:)

🪛 GitHub Actions: PR #1782
scrapers/processors/json.go

[error] 451-451: Result.Pretty undefined. The type 'ScrapeResult' has no field or method 'Pretty'.

🪛 GitHub Actions: Test
scrapers/processors/json.go

[error] 12-12: no required module provides package github.com/flanksource/clicky; to add it:

🪛 GitHub Check: lint
scrapers/processors/json.go

[failure] 451-451:
result.Pretty undefined (type "github.com/flanksource/config-db/api/v1".ScrapeResult has no field or method Pretty) (typecheck)


[failure] 542-542:
input.Debug undefined (type "github.com/flanksource/config-db/api/v1".ScrapeResult has no field or method Debug) (typecheck)


[failure] 541-541:
e.Config.Transform.Script.Pretty undefined (type "github.com/flanksource/config-db/api/v1".Script has no field or method Pretty) (typecheck)


[failure] 535-535:
e.Config.Transform.Script.PrettyShort undefined (type "github.com/flanksource/config-db/api/v1".Script has no field or method PrettyShort) (typecheck)


[failure] 653-653:
input.Debug undefined (type "github.com/flanksource/config-db/api/v1".ScrapeResult has no field or method Debug) (typecheck)

🪛 GitHub Check: test
scrapers/processors/json.go

[failure] 12-12:
no required module provides package github.com/flanksource/clicky; to add it:

🪛 GitHub Check: test-prod
scrapers/processors/json.go

[failure] 12-12:
no required module provides package github.com/flanksource/clicky; to add it:

🔇 Additional comments (7)
scrapers/azure/devops/client.go (2)

42-42: LGTM! Type change enables dynamic parameter values.

The change from map[string]string to map[string]any for TemplateParameters appropriately supports more flexible parameter types in Azure DevOps pipelines and runs.

Also applies to: 88-88


46-57: LGTM! String conversion handles any type correctly.

The use of fmt.Sprintf("%v", v) appropriately converts template parameter values of any type to strings for labels and tags.

Also applies to: 100-109

scrapers/processors/json.go (5)

334-473: Good refactoring into multi-stage pipeline.

The restructuring of Extract() into sequential stages (transform, parseProperties, extractItems, postProcess) improves code organization and maintainability. Each stage has a clear responsibility.


475-511: LGTM! Property parsing extracted with safe Link cloning.

The extraction of property parsing logic is clean, and the safe cloning of Links at lines 490-492 correctly prevents mutation of the original template.


513-530: LGTM! Clean extraction of items logic.

The recursive item extraction is well-structured, correctly calling WithoutItems().Extract() to prevent infinite recursion.


532-557: LGTM! Transform logic well-separated with enhanced error context.

The transformation stage is cleanly extracted with appropriate debug logging and contextual error information.


559-587: LGTM! Post-processing consolidated effectively.

The post-processing stage cleanly consolidates masking, health defaults, and location/alias resolution in a single logical stage.

"strings"
"time"

"github.com/flanksource/clicky"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Missing dependency prevents compilation.

The package github.com/flanksource/clicky is not available in the module dependencies, causing build failures.

Run the following to add the dependency:

#!/bin/bash
# Add the missing dependency
go get github.com/flanksource/clicky
🧰 Tools
🪛 GitHub Actions: Build

[error] 12-12: No required module provides package github.com/flanksource/clicky; to add it: go get github.com/flanksource/clicky

🪛 GitHub Actions: Lint

[error] 12-12: could not import github.com/flanksource/clicky (scrapers/processors/json.go:12:2: no required module provides package github.com/flanksource/clicky; to add it:)

🪛 GitHub Actions: Test

[error] 12-12: no required module provides package github.com/flanksource/clicky; to add it:

🪛 GitHub Check: test

[failure] 12-12:
no required module provides package github.com/flanksource/clicky; to add it:

🪛 GitHub Check: test-prod

[failure] 12-12:
no required module provides package github.com/flanksource/clicky; to add it:

🤖 Prompt for AI Agents
In scrapers/processors/json.go at line 12 the import
"github.com/flanksource/clicky" is referenced but the module is not present in
go.mod, causing compilation failures; add the dependency to the module by
running `go get github.com/flanksource/clicky` (or manually add the appropriate
version to go.mod and run `go mod tidy`) so the package is available for import
and the project builds successfully.

s += fmt.Sprintf(" source=%s", input.Source)
}
if logger.V(2).Enabled() {
logger.V(2).Infof(clicky.Text("").Append(input.Config).ANSI())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

wc -l scrapers/processors/json.go

Repository: flanksource/config-db

Length of output: 96


🏁 Script executed:

head -50 scrapers/processors/json.go

Repository: flanksource/config-db

Length of output: 1217


🏁 Script executed:

# Search for ScrapeResult type definition
ast-grep --pattern 'type ScrapeResult struct {
  $$$
}'

Repository: flanksource/config-db

Length of output: 5467


🏁 Script executed:

# Search for Script type definition
ast-grep --pattern 'type Script struct {
  $$$
}'

Repository: flanksource/config-db

Length of output: 499


🏁 Script executed:

# Search for all methods on ScrapeResult
rg 'func \(\w+\s+\*?ScrapeResult\)' -A 2

Repository: flanksource/config-db

Length of output: 2474


🏁 Script executed:

# Search for all methods on Script
rg 'func \(\w+\s+\*?Script\)' -A 2

Repository: flanksource/config-db

Length of output: 869


🏁 Script executed:

# Check clicky package import and usage
rg 'import.*clicky|clicky\.' scrapers/processors/json.go | head -20

Repository: flanksource/config-db

Length of output: 157


🏁 Script executed:

# Read lines around 433
sed -n '425,440p' scrapers/processors/json.go

Repository: flanksource/config-db

Length of output: 503


🏁 Script executed:

# Read lines around 451
sed -n '445,460p' scrapers/processors/json.go

Repository: flanksource/config-db

Length of output: 543


🏁 Script executed:

# Read lines around 535
sed -n '530,545p' scrapers/processors/json.go

Repository: flanksource/config-db

Length of output: 697


🏁 Script executed:

# Read lines around 653
sed -n '648,660p' scrapers/processors/json.go

Repository: flanksource/config-db

Length of output: 459


🏁 Script executed:

# Search for Pretty() method definitions
rg 'func.*Pretty\(\)' -A 2

Repository: flanksource/config-db

Length of output: 47


🏁 Script executed:

# Search for PrettyShort() method definitions
rg 'func.*PrettyShort\(\)' -A 2

Repository: flanksource/config-db

Length of output: 47


🏁 Script executed:

# Search for Debug() method definitions
rg 'func.*Debug\(\)' -A 2

Repository: flanksource/config-db

Length of output: 182


🏁 Script executed:

# Search for any method on ScrapeResult that might be similar
rg 'func \(\w+\s+\*?ScrapeResult\).*\(\)'

Repository: flanksource/config-db

Length of output: 722


🏁 Script executed:

# Search entire codebase for Pretty/Debug method definitions
rg '\bPretty\(' --type go

Repository: flanksource/config-db

Length of output: 401


🏁 Script executed:

# Search for any Debug method on any type
rg 'func.*Debug\(\).*{' --type go

Repository: flanksource/config-db

Length of output: 164


🏁 Script executed:

# Check if there are any interface definitions that might define these methods
rg 'interface.*{' -A 20 | grep -A 20 'Pretty\|Debug'

Repository: flanksource/config-db

Length of output: 152


🏁 Script executed:

# Look at clicky package imports and see what's available
rg 'clicky\.' scrapers/processors/json.go

Repository: flanksource/config-db

Length of output: 157


🏁 Script executed:

# Search for Debug() method more carefully
rg 'Debug\(' --type go | grep 'func'

Repository: flanksource/config-db

Length of output: 118


🏁 Script executed:

# Check if input has Debug method - look at ScrapeResult more carefully
sed -n '700,900p' api/v1/interface.go | grep -i 'debug\|pretty'

Repository: flanksource/config-db

Length of output: 47


🏁 Script executed:

# Search in the entire api/v1 directory for these methods
find api/v1 -name "*.go" -exec grep -l "Pretty\|Debug" {} \;

Repository: flanksource/config-db

Length of output: 80


Critical: Undefined methods prevent compilation.

Multiple method calls reference methods that don't exist on the respective types:

  • Line 451: ScrapeResult has no Pretty() method
  • Line 535: Script has no PrettyShort() method
  • Line 541: Script has no Pretty() method
  • Lines 542, 653: ScrapeResult has no Debug() method

These methods need to be implemented or the calls need to be replaced with alternative approaches.

Also applies to: 451-451, 535-535, 541-542, 653-653

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.

2 participants