fix: adding map and log for FileServiceConfiguration - BED-9174 - #3118
fix: adding map and log for FileServiceConfiguration - BED-9174#3118mykeelium wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe change introduces an exported file-service configuration map type and adds structured logging throughout file-service provider resolution and service creation. ChangesStorage configuration and resolution
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/api/src/services/storage/fileserviceresolver.go`:
- Around line 196-201: Replace the fmt.Sprintf-based slog.Info calls in the
file-service resolver, including the paths around the configured, provider,
prefix, and backing messages, with literal capitalized message strings and
structured slog attributes. Include the relevant file service, provider, prefix,
and backing values as attributes, and remove the formatting interpolation so all
four calls satisfy sloglint msg-style.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 6c6e5ebf-4d93-45a7-ad98-2890d144cbd0
📒 Files selected for processing (2)
cmd/api/src/config/config.gocmd/api/src/services/storage/fileserviceresolver.go
| slog.Info(fmt.Sprintf( | ||
| "file service %s configured using storage configuration with provider %s and prefix %s", | ||
| definition.Name, | ||
| serviceConfiguration.Provider, | ||
| serviceConfiguration.Prefix, | ||
| )) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -e
file='cmd/api/src/services/storage/fileserviceresolver.go'
printf '%s\n' '--- file outline ---'
ast-grep outline "$file" 2>/dev/null || true
printf '%s\n' '--- imports and relevant logging calls ---'
sed -n '1,80p' "$file"
sed -n '175,235p' "$file"
sed -n '285,325p' "$file"
printf '%s\n' '--- all fmt/slog references in the file ---'
rg -n -C 3 'fmt\.|slog\.(Info|InfoContext|Warn|Error|Debug)' "$file"
printf '%s\n' '--- definitions and usages of referenced types ---'
rg -n -C 2 'type (FileService|Provider|.*Definition)|definition\.Name|resolvedDefinition\.definition|serviceConfiguration\.(Provider|Prefix)' cmd/api/src/services/storage
printf '%s\n' '--- lint configuration ---'
rg -n -C 3 'sloglint|forbidigo|staticcheck|golangci' . -g '*.yml' -g '*.yaml' -g '*.toml' -g '*.json' -g 'Makefile' -g '*.mk' -g '*.go' || true
printf '%s\n' '--- license header reference and target header ---'
head -n 12 LICENSE.header
head -n 12 "$file"
printf '%s\n' '--- repository status summary ---'
git diff --statRepository: SpecterOps/BloodHound
Length of output: 26382
🏁 Script executed:
#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path
import json, re
source_path = Path("cmd/api/src/services/storage/fileserviceresolver.go")
config_path = Path(".golangci.json")
source = source_path.read_text()
config = json.loads(config_path.read_text())
slog_calls = []
for match in re.finditer(r'slog\.(Info|InfoContext)\s*\(', source):
start = match.start()
end = source.find(")", start)
# Capture enough source to classify the first argument without executing code.
call = source[start:end + 1]
line = source.count("\n", 0, start) + 1
slog_calls.append((line, match.group(1), call.replace("\n", " ")))
print("sloglint settings:", config["linters"]["settings"]["sloglint"])
print("slog calls whose first argument is fmt.Sprintf:")
for line, method, call in slog_calls:
if "fmt.Sprintf" in call:
print(f"{line}: slog.{method} -> {call}")
expected_lines = [196, 222, 304, 313]
actual_lines = [line for line, _, call in slog_calls if "fmt.Sprintf" in call]
print("dynamic-call line check:", actual_lines == expected_lines, actual_lines)
for line in expected_lines:
text = source.splitlines()[line - 1]
print(f"{line}: {text.strip()}")
PY
printf '%s\n' '--- exact sloglint configuration ---'
sed -n '88,105p' .golangci.json
printf '%s\n' '--- referenced type declarations ---'
rg -n -C 3 'type FileServiceName|type fileServiceProvider|type FileServiceConfiguration struct' packages cmd/api/srcRepository: SpecterOps/BloodHound
Length of output: 3262
Use literal, capitalized slog messages with structured attributes. Replace the four fmt.Sprintf calls at lines 196, 222, 304, and 313. Add attributes for the file service, provider, prefix, and backing. Use capitalized messages to satisfy sloglint's msg-style setting.
🧰 Tools
🪛 golangci-lint (2.12.2)
[major] 196-196: message should be a string literal or a constant
(sloglint)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@cmd/api/src/services/storage/fileserviceresolver.go` around lines 196 - 201,
Replace the fmt.Sprintf-based slog.Info calls in the file-service resolver,
including the paths around the configured, provider, prefix, and backing
messages, with literal capitalized message strings and structured slog
attributes. Include the relevant file service, provider, prefix, and backing
values as attributes, and remove the formatting interpolation so all four calls
satisfy sloglint msg-style.
Source: Linters/SAST tools
Description
Adding logging around feature for FileServiceConfiguration
Motivation and Context
Resolves BED-9174
Why is this change required? What problem does it solve?
How Has This Been Tested?
Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc.
Screenshots (optional):
Types of changes
Checklist:
Summary by CodeRabbit