Skip to content

Feat/ssad 0099/azure blobe storage#108

Open
Sohatzk wants to merge 13 commits into
devfrom
feat/SSAD-0099/azure-blobe-storage
Open

Feat/ssad 0099/azure blobe storage#108
Sohatzk wants to merge 13 commits into
devfrom
feat/SSAD-0099/azure-blobe-storage

Conversation

@Sohatzk
Copy link
Copy Markdown
Contributor

@Sohatzk Sohatzk commented Feb 25, 2026

Added azure blob storage
Moved Encryption/Decryption logic to a separate shared service
Added blob existence validation logic
Added unit tests for new logic
#99

Copy link
Copy Markdown
Contributor

@DrFaust555 DrFaust555 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Problem: missing else/continue in ~7 handlers
    Repeats in GetAllAudiosHandler, GetAllImagesHandler, GetImageByStreetcodeIdHandler, GetStreetcodeArtByStreetcodeIdHandler, GetAllCategoriesHandler, GetCategoriesByStreetcodeIdHandler, GetArtsByStreetcodeIdHandler:

var audioBase64 = await _blobService.FindFileInStorageAsBase64(audio.BlobName);
if (audioBase64 is not null)
{
audio.Base64 = audioBase64;
}
// BUG: this code is ALWAYS executed — even when the blob is found!
var errorNotFoundMsg = Messages.Error_MediaBlobNotFound.Format(...);
_logger.LogError(request, errorNotFoundMsg);
return Result.Fail(new Error(errorNotFoundMsg));
There is no else or continue after if — the handler always returns Fail, even when the blob is found successfully. GetAllNewsHandler and SortedByDateTimeHandler have the correct continue — this is a copy-paste error where continue was forgotten to be added in the rest.

Other inaccuracies:

  1. Program.cs hardcodes AzureBlobService in RecurringJob:
    RecurringJob.AddOrUpdate(...)
    In Local environment AzureBlobService is not registered — will fail. IBlobService is required.
  2. AzureBlobService.FindFileInStorageAsBytes returns null! — null-forgiving operator hides potential NullReferenceException. Return type should be Task<byte[]?>.
  3. BlobService.SaveFileInStorageBase64 is broken — the result of FileService.EncryptFile() is discarded, unencrypted bytes are written to disk.
  4. UpdateNewsHandler — Delete(newsEntity.Image) without null-check — if newsEntity.Image is also null, there will be a NullReferenceException.
  5. AzureBlobService uses Console.WriteLine instead of ILogger for logging.
  6. CleanBlobStorage loads ALL images and audios into memory via GetAllAsync() — a problem with large data.

Design issues
8. 0% tests on AzureBlobService and FileService — new 200+ lines of production code without coverage.
9. 9.9% duplication — blob-not-found pattern copy-pasted in 20 handlers. Should be moved to helper.

- Optimize AzureBlobService.CleanBlobStorage with batching and logging; delete only unreferenced blobs
- Use EncryptBytes/DecryptBytes for clearer encryption logic
- Add early continue in MediatR handlers after successful Base64 retrieval
- Update UpdateNewsHandler to avoid deleting images linked to Facts
- Improve and expand unit tests for blob and news update logic
- Register blob cleanup Hangfire job via IBlobService interface
- Add StyleCop suppressions and enhance logging throughout blob services
#99
@Sohatzk Sohatzk requested a review from DrFaust555 February 27, 2026 13:28
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 2, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
67.8% Coverage on New Code (required ≥ 80%)
5.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants