-
Notifications
You must be signed in to change notification settings - Fork 19
Pr/fix azure #1782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Pr/fix azure #1782
Conversation
WalkthroughAzure DevOps client changes TemplateParameters field type from Changes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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
%sfor the value, butvis nowanytype. 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
📒 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]stringtomap[string]anyfor 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
wc -l scrapers/processors/json.goRepository: flanksource/config-db
Length of output: 96
🏁 Script executed:
head -50 scrapers/processors/json.goRepository: 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 2Repository: flanksource/config-db
Length of output: 2474
🏁 Script executed:
# Search for all methods on Script
rg 'func \(\w+\s+\*?Script\)' -A 2Repository: flanksource/config-db
Length of output: 869
🏁 Script executed:
# Check clicky package import and usage
rg 'import.*clicky|clicky\.' scrapers/processors/json.go | head -20Repository: flanksource/config-db
Length of output: 157
🏁 Script executed:
# Read lines around 433
sed -n '425,440p' scrapers/processors/json.goRepository: flanksource/config-db
Length of output: 503
🏁 Script executed:
# Read lines around 451
sed -n '445,460p' scrapers/processors/json.goRepository: flanksource/config-db
Length of output: 543
🏁 Script executed:
# Read lines around 535
sed -n '530,545p' scrapers/processors/json.goRepository: flanksource/config-db
Length of output: 697
🏁 Script executed:
# Read lines around 653
sed -n '648,660p' scrapers/processors/json.goRepository: flanksource/config-db
Length of output: 459
🏁 Script executed:
# Search for Pretty() method definitions
rg 'func.*Pretty\(\)' -A 2Repository: flanksource/config-db
Length of output: 47
🏁 Script executed:
# Search for PrettyShort() method definitions
rg 'func.*PrettyShort\(\)' -A 2Repository: flanksource/config-db
Length of output: 47
🏁 Script executed:
# Search for Debug() method definitions
rg 'func.*Debug\(\)' -A 2Repository: 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 goRepository: flanksource/config-db
Length of output: 401
🏁 Script executed:
# Search for any Debug method on any type
rg 'func.*Debug\(\).*{' --type goRepository: 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.goRepository: 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:
ScrapeResulthas noPretty()method - Line 535:
Scripthas noPrettyShort()method - Line 541:
Scripthas noPretty()method - Lines 542, 653:
ScrapeResulthas noDebug()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
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.