{"record":{"id":"3207ba88ad1f6746","repo":"microsoft/aspire","slug":"import-is-disabled","errorCode":null,"errorMessage":"Import is disabled.","messagePattern":"Import is disabled\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Dashboard/Model/TelemetryImportService.cs","lineNumber":64,"sourceCode":"        _logger = logger;\n        _activitySource = activitySource.ActivitySource;\n    }\n\n    /// <summary>\n    /// Imports telemetry data from a file stream.\n    /// </summary>\n    /// <param name=\"fileName\">The name of the file being imported.</param>\n    /// <param name=\"stream\">The file stream.</param>\n    /// <param name=\"cancellationToken\">Cancellation token.</param>\n    /// <returns>A task representing the async operation.</returns>\n    /// <exception cref=\"InvalidOperationException\">Thrown when import is disabled.</exception>\n    public async Task ImportAsync(string fileName, Stream stream, CancellationToken cancellationToken)\n    {\n        using var activity = _activitySource.StartActivity(\"Import telemetry data\", ActivityKind.Internal);\n\n        if (!IsImportEnabled)\n        {\n            throw new InvalidOperationException(\"Import is disabled.\");\n        }\n\n        await ImportCoreAsync(fileName, stream, allowZipFile: true, cancellationToken).ConfigureAwait(false);\n    }\n\n    private async Task ImportCoreAsync(string fileName, Stream stream, bool allowZipFile, CancellationToken cancellationToken)\n    {\n        var extension = Path.GetExtension(fileName).ToLowerInvariant();\n\n        switch (extension)\n        {\n            case \".zip\":\n                if (!allowZipFile)\n                {\n                    // Allowing zip file is a flag to not extract zip files inside zip files. Avoid unexpected recursion.\n                    goto default;\n                }\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Dashboard/Model/TelemetryImportService.cs#L46-L82","documentation":"TelemetryImportService.ImportAsync first checks IsImportEnabled, which reflects whether the dashboard was launched with telemetry import allowed. When the feature is off, the method throws InvalidOperationException(\"Import is disabled.\") before touching the stream — import is opt-in for security reasons.","triggerScenarios":"Calling ImportAsync when the dashboard was started without the import-enabling configuration (the ASPIRE_DASHBOARD_OTLP_WITH_TELEMETRY_IMPORT / enable-telemetry-import settings), or in a client embedding the dashboard with import disabled by default.","commonSituations":"Running the dashboard in production/default mode where import is disabled; forgetting to pass the feature flag or launch argument when automating imports; tests invoking the service against a default-constructed options object.","solutions":["Enable telemetry import on dashboard startup (set the telemetry-import feature configuration, e.g. Dashboard:Otlp:WithTelemetryImport / corresponding CLI flag)","Check TelemetryImportService.IsImportEnabled before attempting an import and surface a friendly message","Restart the dashboard with import enabled, then retry the import","If import isn't available, view telemetry live via OTLP instead of importing a file"],"exampleFix":"// before\nawait telemetryImportService.ImportAsync(file.Name, fileStream, ct);\n// after\nif (!telemetryImportService.IsImportEnabled)\n{\n    throw new InvalidOperationException(\"Enable telemetry import on the dashboard before importing files.\");\n}\nawait telemetryImportService.ImportAsync(file.Name, fileStream, ct);","handlingStrategy":"validation","validationCode":"if (!telemetryImportService.IsImportEnabled)\n    throw new InvalidOperationException(\"Telemetry import is disabled. Start the dashboard with telemetry import enabled.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await importService.ImportAsync(fileName, stream, ct);\n}\ncatch (InvalidOperationException ex) when (ex.Message == \"Import is disabled.\")\n{\n    console.WriteLine(\"Import is disabled: restart the dashboard with telemetry import enabled.\");\n}","preventionTips":["Check IsImportEnabled before building import UIs or automation","Launch the dashboard with the telemetry-import feature flag enabled when imports are needed","Document the required launch configuration for import workflows"],"tags":["feature-flag","telemetry","import","dashboard"],"backgroundTag":"feature-not-enabled","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}