Skip to content

refactor(foundation): decouple up/down commands and suppress unregistered binding noise#1431

Merged
hwbrzzl merged 1 commit into
masterfrom
bowen/optimize-up-down
Mar 30, 2026
Merged

refactor(foundation): decouple up/down commands and suppress unregistered binding noise#1431
hwbrzzl merged 1 commit into
masterfrom
bowen/optimize-up-down

Conversation

@hwbrzzl

@hwbrzzl hwbrzzl commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • up and down commands now receive explicit dependencies instead of the full Application object
  • defaultCommands() consolidates command registration and conditionally includes up/down only when Storage, View, and Hash are bound
  • MakeX() container methods no longer print to the terminal when a binding is simply unregistered; other errors still log

Why

The up and down commands previously accepted foundation.Application in their constructors and called MakeStorage(), MakeView(), and MakeHash() immediately. When those bindings were not registered yet (e.g. during Boot()), every Make* call printed a spurious "binding not found" error to the terminal. By injecting the resolved values directly and guarding their inclusion behind nil checks, construction is side-effect free and the commands only appear when their dependencies are actually available.

// Before: constructor resolves from app at construction time
func NewDownCommand(app foundation.Application) *DownCommand {
    return &DownCommand{app, app.MakeView(), app.MakeHash(), app.MakeStorage()}
}

// After: resolved values are passed in
func NewDownCommand(view view.View, hash hash.Hash, storage filesystem.Storage) *DownCommand {
    return &DownCommand{view, hash, storage}
}

A companion change introduces BindingNotFoundError so that logMakeErrorIfNeeded can distinguish a missing optional binding from a genuine resolution failure. Only real errors are printed now.

// Before: always printed, even for unregistered optional services
color.Errorln(err)

// After: only logs genuine errors; silences BindingNotFoundError
func logMakeErrorIfNeeded(err error) {
    var bindingNotFoundErr *BindingNotFoundError
    if !errors.As(err, &bindingNotFoundErr) {
        color.Errorln(err)
    }
}

@hwbrzzl
hwbrzzl requested a review from a team as a code owner March 30, 2026 07:43
@codecov

codecov Bot commented Mar 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.83%. Comparing base (31637df) to head (bec4ebf).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
foundation/application.go 9.52% 19 Missing ⚠️
foundation/container.go 94.73% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1431      +/-   ##
==========================================
+ Coverage   68.28%   68.83%   +0.55%     
==========================================
  Files         357      357              
  Lines       27682    27685       +3     
==========================================
+ Hits        18903    19058     +155     
+ Misses       7933     7782     -151     
+ Partials      846      845       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl hwbrzzl changed the title optimize output refactor(foundation): decouple up/down commands and suppress unregistered binding noise Mar 30, 2026
@hwbrzzl
hwbrzzl merged commit 69923e3 into master Mar 30, 2026
16 of 18 checks passed
@hwbrzzl
hwbrzzl deleted the bowen/optimize-up-down branch March 30, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant