Skip to content

FileSystemScheduleMonitor crash when working directory contains the text "jobs" #927

@belcher-rok

Description

@belcher-rok

Problem

The FileSystemScheduleMonitor c'tor will throw an ArgumentOutOfRangeException when the following conditions are met:

  1. The current working directory contains the string "jobs".
  2. The HOME environment variable exists

Steps to reproduce

  1. Create a WebJobs application
  2. Add a package reference to Microsoft.Azure.WebJobs.Extensions v5.0.
  3. Call AddTimers() on the WebJobs Host Builder.
  4. Build and run the Host to make sure it works without error.
  5. Rename the directory containing our app assembly to "WebJobs" (or "xxxxjobsxxxx").
  6. If on Windows, create a non-empty environment variable named "HOME".
  7. cd into the "WebJobs" folder from step 4 and launch the app (e.g. dotnet testapp.dll).

The app should throw an ArgumentOutOfRangeException on startup.

Workarounds

  1. Change the application's working directory to somewhere else, such as the Temp folder.
  2. Replace the registered ScheduleMonitor with one which uses a different working folder.
    After calling .AddTimers(), register a replacement ScheduleMonitor using
    using Microsoft.Azure.WebJobs.Extensions.Timers;
    ...
    services.AddSingleton<ScheduleMonitor>(_ => new FileSystemScheduleMonitor(Path.GetTempFolder()));

Discussion

I found this when using a linux container based on mcr.microsoft.com/dotnet/aspnet:9.0.

An easy solution to the crash is to change line 51 to if (start > 0 && end > start), but I'm not sure that addresses the larger issue of assuming that the app is running out of TEMP directory.

Version Info

  • .NET SDK 9.0.102
  • Microsoft.Azure.WebJobs 3.0.41
  • Microsoft.Azure.WebJobs.Extensions 5.0
  • TargetFramework: net9.0

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