Skip to content

CIFSClient throws NullReferenceException on Linux when no cached auth-store entry exists for a UNC repository #777

Description

@joaovent15

Summary

On any non-Windows platform, constructing any BaseCommand-derived command crashes with an
unhandled NullReferenceException if the repository's repositories.json lists a UNC-style
repository and no credentials have ever been saved for it via cmf login. The crash happens during
CLI bootstrap/command-tree discovery — before any command's actual logic runs — so it breaks every
plugin command uniformly, not just the one the user is trying to run.

Where

  • core/Objects/ExecutionContext.cs, line 115 — the CIFS-connecting block is gated by
    !RunningOnWindows && RepositoriesConfig.Repositories.HasAny(), so it's silently skipped on
    Windows and only exercised on Linux/macOS.

  • core/Objects/CIFSClient.cs, constructor (lines 30-36) — the actual crash site:

    public CIFSClient(Uri uri, ISMBClient smbClient = null)
    {
        var authStore = ExecutionContext.ServiceProvider.GetService<IRepositoryAuthStore>();
        Server = uri.Host;
        _smbClient = smbClient ?? new SMB2Client();
        _credentials = authStore.GetCredentialsFor<CIFSRepositoryCredentials>(authStore.GetOrLoad().GetAwaiter().GetResult(), uri.AbsoluteUri);
        // ^ NullReferenceException here when authStore has no entry at all for this repository

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions