Skip to content

Storage name validation - #4881

Merged
gabrielbeamable merged 5 commits into
mainfrom
issue/storage-name-validation
Oct 7, 2026
Merged

gabrielbeamable merged 5 commits into
mainfrom
issue/storage-name-validation

Conversation

@gabrielbeamable

Copy link
Copy Markdown
Contributor

Summary

A storage's MongoDB database is named {cid}{pid|zid}_{storageName}, and MongoDB rejects database names longer than 63 characters, both locally and on Atlas. Until now nothing checked this, so a long storage name only failed on its first database call, with a bare InvalidNamespace error. This PR adds CLI and runtime checks that report the problem earlier, with a clear message (phase 1; server-side validation in BeamableAPI follows separately).

Changes

  • StorageDatabaseName (in StorageObjectConnectionProvider.cs): the database-name rule (63 max, compose, budget, message), shared by the microservice runtime and the CLI
  • Microservice runtime: GetDatabaseByStorageName throws StorageNameTooLongException before the first database call
  • StorageNameValidator: FindTooLong / ThrowIfAny (local storages only, all offenders reported at once), and ValidateNewStorage
  • beam project new storage: fails before creating files when the name doesn't fit the current realm/zone; warns (worst-case budget) when the target is unknown
  • Manifest init (BeamoLocalSystem.InitManifest): offline check against cid + pid, or the local zid for zone storages; catches storages renamed by hand and blocks project run
  • Deploy plan: checks against the resolved deploy target (incl. the realm's bound zone) before any image build
  • CliRequester.GetEffectiveScopeIds(): shared parse of the {cid}.{zid} scope override; ServiceUploadUtil now uses it
  • Console only: the CliException message is repeated in red as the last line of output (skipped for pipe/raw output)

Example error:

Storage [OkNameStorageThatIsTooLong] is too long for realm [DE_102143049521403906]: its MongoDB database name
[101079206070147072DE_102143049521403906_OkNameStorageThatIsTooLong] would be 66 characters, but MongoDB allows
at most 63. Storage names in this realm can be at most 23 characters.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Lightbeam link

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Lightbeam link

public override async Task Handle(NewStorageCommandArgs args)
{
await args.CreateConfigIfNeeded(_initCommand);
StorageNameValidator.ValidateNewStorage(args.AppContext.Cid, await ResolveTargetScope(args), args.ProjectName,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

move the storageNameValidator to live along the CreateNewStorage instead of having its own class

@gabrielbeamable
gabrielbeamable merged commit 37b4feb into main Oct 7, 2026
5 checks passed
@gabrielbeamable
gabrielbeamable deleted the issue/storage-name-validation branch October 7, 2026 20:28
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Lightbeam link

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.

1 participant