Skip to content

fix: adding map and log for FileServiceConfiguration - BED-9174 - #3118

Open
mykeelium wants to merge 1 commit into
mainfrom
mcuomo/BED-9174
Open

fix: adding map and log for FileServiceConfiguration - BED-9174#3118
mykeelium wants to merge 1 commit into
mainfrom
mcuomo/BED-9174

Conversation

@mykeelium

@mykeelium mykeelium commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

  • Chore (a change that does not modify the application functionality)

Checklist:

Summary by CodeRabbit

  • New Features
    • Added clearer diagnostic logging when configuring file storage services.
    • Added logging for S3 client setup and local or S3 storage service creation.

@mykeelium mykeelium self-assigned this Aug 7, 2026
@mykeelium mykeelium added the api A pull request containing changes affecting the API code. label Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change introduces an exported file-service configuration map type and adds structured logging throughout file-service provider resolution and service creation.

Changes

Storage configuration and resolution

Layer / File(s) Summary
File-service configuration contract
cmd/api/src/config/config.go
Adds FileServiceConfigurationMap and uses it for StorageConfiguration.FileServices. The JSON field remains file_services.
File-service resolution logging
cmd/api/src/services/storage/fileserviceresolver.go
Adds logs for configured providers, resolved providers, S3 client creation, and local or S3 file-service creation.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: lawsonwillard

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary changes: adding a map type and logging for FileServiceConfiguration.
Description check ✅ Passed The description includes the required sections, linked ticket, change type, and completed checklist, but provides limited motivation and testing details.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mcuomo/BED-9174

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0862158 and 84d664b.

📒 Files selected for processing (2)
  • cmd/api/src/config/config.go
  • cmd/api/src/services/storage/fileserviceresolver.go

Comment on lines +196 to +201
slog.Info(fmt.Sprintf(
"file service %s configured using storage configuration with provider %s and prefix %s",
definition.Name,
serviceConfiguration.Provider,
serviceConfiguration.Prefix,
))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 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 --stat

Repository: 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/src

Repository: 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

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

Labels

api A pull request containing changes affecting the API code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant