Skip to content

Drop failed runtime prototype uploads. - #6548

Open
rhailrake wants to merge 4 commits into
space-wizards:masterfrom
rhailrake:fix/6502-drop-bad-prototype-uploads
Open

Drop failed runtime prototype uploads.#6548
rhailrake wants to merge 4 commits into
space-wizards:masterfrom
rhailrake:fix/6502-drop-bad-prototype-uploads

Conversation

@rhailrake

Copy link
Copy Markdown
Contributor

Fixes #6502.

Runtime prototype uploads now fail as a transaction: bad uploads are dropped before being added to replay state or broadcast to clients.

If loading an upload partially mutates prototype state before failing, the prototype manager is reset and previously accepted uploads are reapplied. Strict reload validation is used for uploads so validation-only failures are rejected too, while normal prototype reload behavior remains unchanged.

Comment thread Robust.Shared/Upload/SharedPrototypeLoadManager.cs Outdated
Comment thread Robust.Shared/Upload/SharedPrototypeLoadManager.cs Outdated
Comment on lines +501 to +524
private void ValidatePrototype(
Type kind,
string id,
MappingDataNode mapping,
YamlValidationContext context)
{
var validationMapping = mapping;
if (mapping.Has("type"))
{
// Runtime-loaded mappings still include "type"; field validation already knows the prototype kind.
validationMapping = mapping.Copy();
validationMapping.Remove("type");
}

var errors = _serializationManager.ValidateNode(kind, validationMapping, context)
.GetErrors()
.ToArray();

if (errors.Length == 0)
return;

var errorText = string.Join("\n", errors.Select(x => x.ErrorReason));
throw new PrototypeLoadException($"Validation failed for {kind}({id})\n{errorText}");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I need to inspect this in more detail.

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.

No problem. I also added a regression case for a partially valid upload to verify that the previously accepted prototype state is restored after a failure.

@rhailrake
rhailrake marked this pull request as draft August 6, 2026 04:46
@rhailrake
rhailrake marked this pull request as ready for review August 6, 2026 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

One bad prototype can cause a lot of issues

2 participants