Verified finding (same anti-pattern as PR #103, sibling service)
FileProcessingService (blog media uploads) calls Directory.CreateDirectory(_uploadPath) in its constructor (FileProcessingService.cs:49). The service is DI-injected into blog media command handlers (AddMediaFilesToPost, CreateBlogPostWithFiles), so a constructor that performs filesystem I/O fails construction — and 500s every blog-upload endpoint that depends on it — if Blogs:StagingPath is unwritable/misconfigured (e.g. a container path like /app/uploads/blogs on a read-only host).
This is the same defect fixed for LessonVideoStagingService in spikersoft-backend#103, and it's the last remaining instance of the ctor-filesystem-I/O pattern (swept SpikerSoft.Business / SpikerSoft.Api: only these two services did I/O in a constructor; the rest do it inside command handlers, which is fine).
Redundant anyway
ProcessUploadedFileAsync already creates the directory lazily at the point of use:
So the constructor call adds no value and only broadens the blast radius of a bad path.
Fix (in flight)
Remove the constructor's Directory.CreateDirectory. Construction now performs no filesystem I/O; only an actual upload fails if the path is genuinely unwritable. Adds a regression test asserting the ctor neither throws nor creates the directory. Build-clean + test green.
## Verified finding (same anti-pattern as PR #103, sibling service)
`FileProcessingService` (blog media uploads) calls `Directory.CreateDirectory(_uploadPath)` in its **constructor** (`FileProcessingService.cs:49`). The service is DI-injected into blog media command handlers (`AddMediaFilesToPost`, `CreateBlogPostWithFiles`), so a constructor that performs filesystem I/O fails construction — and **500s every blog-upload endpoint that depends on it** — if `Blogs:StagingPath` is unwritable/misconfigured (e.g. a container path like `/app/uploads/blogs` on a read-only host).
This is the same defect fixed for `LessonVideoStagingService` in spikersoft-backend#103, and it's **the last remaining instance** of the ctor-filesystem-I/O pattern (swept `SpikerSoft.Business` / `SpikerSoft.Api`: only these two services did I/O in a constructor; the rest do it inside command handlers, which is fine).
### Redundant anyway
`ProcessUploadedFileAsync` already creates the directory lazily at the point of use:
```csharp
if (!Directory.Exists(_uploadPath)) { Directory.CreateDirectory(_uploadPath); }
```
So the constructor call adds no value and only broadens the blast radius of a bad path.
## Fix (in flight)
Remove the constructor's `Directory.CreateDirectory`. Construction now performs no filesystem I/O; only an actual upload fails if the path is genuinely unwritable. Adds a regression test asserting the ctor neither throws nor creates the directory. Build-clean + test green.
Resolved in spikersoft-backend PR #105 (merged to master). Removed the redundant Directory.CreateDirectory from FileProcessingService's constructor (ProcessUploadedFileAsync already creates it lazily at point-of-use), so construction no longer performs filesystem I/O and a bad Blogs:StagingPath can't 500 blog-upload endpoints. Added FileProcessingServiceTests regression guard. This clears the last ctor-filesystem-I/O instance in the codebase. Closing.
Resolved in spikersoft-backend PR #105 (merged to `master`). Removed the redundant `Directory.CreateDirectory` from `FileProcessingService`'s constructor (`ProcessUploadedFileAsync` already creates it lazily at point-of-use), so construction no longer performs filesystem I/O and a bad `Blogs:StagingPath` can't 500 blog-upload endpoints. Added `FileProcessingServiceTests` regression guard. This clears the last ctor-filesystem-I/O instance in the codebase. Closing.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Verified finding (same anti-pattern as PR #103, sibling service)
FileProcessingService(blog media uploads) callsDirectory.CreateDirectory(_uploadPath)in its constructor (FileProcessingService.cs:49). The service is DI-injected into blog media command handlers (AddMediaFilesToPost,CreateBlogPostWithFiles), so a constructor that performs filesystem I/O fails construction — and 500s every blog-upload endpoint that depends on it — ifBlogs:StagingPathis unwritable/misconfigured (e.g. a container path like/app/uploads/blogson a read-only host).This is the same defect fixed for
LessonVideoStagingServicein spikersoft-backend#103, and it's the last remaining instance of the ctor-filesystem-I/O pattern (sweptSpikerSoft.Business/SpikerSoft.Api: only these two services did I/O in a constructor; the rest do it inside command handlers, which is fine).Redundant anyway
ProcessUploadedFileAsyncalready creates the directory lazily at the point of use:So the constructor call adds no value and only broadens the blast radius of a bad path.
Fix (in flight)
Remove the constructor's
Directory.CreateDirectory. Construction now performs no filesystem I/O; only an actual upload fails if the path is genuinely unwritable. Adds a regression test asserting the ctor neither throws nor creates the directory. Build-clean + test green.Resolved in spikersoft-backend PR #105 (merged to
master). Removed the redundantDirectory.CreateDirectoryfromFileProcessingService's constructor (ProcessUploadedFileAsyncalready creates it lazily at point-of-use), so construction no longer performs filesystem I/O and a badBlogs:StagingPathcan't 500 blog-upload endpoints. AddedFileProcessingServiceTestsregression guard. This clears the last ctor-filesystem-I/O instance in the codebase. Closing.