Field notes
An integration is not operationally optional if importing it can stop the entire application from starting. Load it at the feature boundary and make unavailable dependencies an explicit, recoverable state.
Follow the startup import chain
A cloud client imported at module scope can be evaluated before the feature is called and before its error handler exists. In our text-to-speech work, loading an optional provider too early could stop unrelated API functionality when its package or credentials were unavailable. The problem belonged to the startup dependency boundary, not to the audio player’s appearance.
Initialize where the feature is used
Load and initialize the client inside the service that needs it, with an error the caller can handle. A dynamic import is useful when the package is optional, but it does not make authentication or network errors disappear. Separate configuration validation, client creation and the actual request so the team can see which stage failed.
Define a fallback that preserves the user’s intent
A fallback can be another provider, a retry or an honest unavailable state. It should not silently change the meaning of the action or repeatedly retry work that will never succeed. For speech, a second provider may be acceptable; for a financial write, quietly substituting behavior usually is not. Keep logs actionable without including credentials or sensitive content.
Prove the rest of the product still works
Test startup without optional credentials, failure during initialization, provider timeout and a failed fallback. Verify an unrelated route or workflow in the same test environment. Restore the provider and confirm the feature can recover. These checks protect a real product boundary rather than simply asserting that a mock function was called.
- Application starts when the optional integration is unavailable
- The affected feature reports a useful state
- Fallback and retry rules are bounded
- Unrelated workflows stay usable
- Recovery is visible and credentials stay out of logs
Sources and further reading
Have a problem in mind?
Tell us what you want to change. We’ll work out the next step together.