ppy/osu · error · InvalidOperationException
Using the {nameof(OsuTestScene)} dummy API is not supported
Error message
Using the {nameof(OsuTestScene)} dummy API is not supported when {nameof(UseOnlineAPI)} is true What it means
OsuTestScene.API is a convenience accessor for the in-process DummyAPIAccess. When a test scene overrides UseOnlineAPI => true, no DummyAPIAccess is created (the real OsuGameBase IAPIProvider is used instead), so reading the dummy-backed API property is invalid and throws.
Source
Thrown at osu.Game/Tests/Visual/OsuTestScene.cs:61
[Cached]
protected Bindable<WorkingBeatmap> Beatmap { get; } = new Bindable<WorkingBeatmap>();
[Cached]
protected Bindable<RulesetInfo> Ruleset { get; } = new Bindable<RulesetInfo>();
[Cached]
protected Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
protected new DependencyContainer Dependencies { get; private set; }
protected IResourceStore<byte[]> Resources;
protected IAPIProvider API
{
get
{
if (UseOnlineAPI)
throw new InvalidOperationException($"Using the {nameof(OsuTestScene)} dummy API is not supported when {nameof(UseOnlineAPI)} is true");
return dummyAPI;
}
}
private DummyAPIAccess dummyAPI;
/// <summary>
/// Whether this test scene requires real-world API access.
/// If true, this will bypass the local <see cref="DummyAPIAccess"/> and use the <see cref="OsuGameBase"/> provided one.
/// </summary>
protected virtual bool UseOnlineAPI => false;
/// <summary>
/// A database context factory to be used by test runs. Can be isolated and reset by setting <see cref="UseFreshStoragePerRun"/> to <c>true</c>.
/// </summary>
/// <remarks>
/// In interactive runs (ie. VisualTests) this will use the user's database if <see cref="UseFreshStoragePerRun"/> is not set to <c>true</c>.
View on GitHub (pinned to d9c73e12ad)
Solutions
- Do not read OsuTestScene.API when UseOnlineAPI is true; resolve IAPIProvider from dependencies via [Resolved].
- Keep UseOnlineAPI => false if the test genuinely needs the DummyAPIAccess.
- Gate any dummy-specific access behind `if (!UseOnlineAPI)`.
Example fix
// before
protected override bool UseOnlineAPI => true;
var api = API; // throws
// after
protected override bool UseOnlineAPI => true;
[Resolved]
private IAPIProvider api { get; set; } Defensive patterns
Strategy: validation
Validate before calling
IAPIProvider api = UseOnlineAPI
? Dependencies.Get<IAPIProvider>() // real OsuGameBase API
: API; // DummyAPIAccess
// use `api`, never read OsuTestScene.API when UseOnlineAPI is true Prevention
- When flipping UseOnlineAPI => true, audit every read of the inherited API property.
- Prefer [Resolved] IAPIProvider over OsuTestScene.API in test scenes.
- Gate dummy-API-specific helpers behind if (!UseOnlineAPI).
When it happens
Trigger: A test scene sets UseOnlineAPI => true and then reads the inherited `API` property (or otherwise relies on the dummy API).
Common situations: Opting a test into real online-API access while legacy code paths still read OsuTestScene.API; copying a dummy-API-based test and flipping UseOnlineAPI.
Related errors
- Beatmap submission not supported in this configuration!
- Beatmap submission not supported in this configuration!
- Beatmap submission not supported in this configuration!
- A channel with the name {channelName} could not be found.
- Accessing the client-side API room via {nameof(TestMultiplay
AI-assisted analysis of ppy/osu@d9c73e12ad (2026-08-13).
Data as JSON: /api/errors/a19d12e0c737f063.
Report an issue: GitHub.