Skip to content

Conversation

fazeelzafar
Copy link
Contributor

@fazeelzafar fazeelzafar commented Sep 21, 2025

📝 Description

Fixed two critical storage-related bugs in the SmythOS SRE monorepo:

  1. StorageInstance.exists returns boolean: Fixed method to return Promise<boolean> instead of URI string, resolving type contract violations and preventing logic errors in conditional statements.

  2. LocalStorage undefined folder handling: Added null check in findStorageFolder() to prevent crashes when folder parameter is undefined, matching the safer pattern used in NKVLocalStorage.

Both fixes maintain backward compatibility, follow existing code patterns, and include comprehensive test coverage.

🔗 Related Issues

  • Fixes #
  • Relates to #

🔧 Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 📚 Documentation update
  • 🔧 Code refactoring (no functional changes)
  • 🧪 Test improvements
  • 🔨 Build/CI changes

✅ Checklist

  • Self-review performed
  • Tests added/updated
  • Documentation updated (if needed)

Tests Added

  • Core: LocalStorage.test.ts - Validates initialization with undefined folder parameters

Technical Details

Files Changed:

  • packages/sdk/src/Storage/StorageInstance.class.ts - Fixed exists() return type
  • packages/core/src/subsystems/IO/Storage.service/connectors/LocalStorage.class.ts - Added undefined guard
  • packages/core/tests/unit/core/LocalStorage.test.ts - New test coverage

Validation:

  • ✅ Workspace build passes
  • ✅ TypeScript compilation successful
  • ✅ All new tests passing
  • ✅ No breaking changes to public API

@alaa-eddine-k
Copy link
Contributor

Hi @fazeelzafar Thank you for your contribution.

we recently introduced comprehensive unit-tests in the /dev branch.

could you please pull and test your PR on it and add your unit test to https://github.com/SmythOS/sre/blob/dev/packages/core/tests/unit/005-Storage/LocalStorage.test.ts if it's relevant or just remove it ?

@fazeelzafar
Copy link
Contributor Author

Hi @fazeelzafar Thank you for your contribution.

we recently introduced comprehensive unit-tests in the /dev branch.

could you please pull and test your PR on it and add your unit test to https://github.com/SmythOS/sre/blob/dev/packages/core/tests/unit/005-Storage/LocalStorage.test.ts if it's relevant or just remove it ?

Hi there!

Sure, I'll do this.

@fazeelzafar fazeelzafar force-pushed the fix/storage-exists-boolean-and-folder-guard branch from 3863ac4 to f45df8d Compare September 21, 2025 23:16
@fazeelzafar fazeelzafar changed the base branch from main to dev September 21, 2025 23:20
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.

2 participants