Skip to content

[Code Quality] AppConfig — MaxConfigFileSizeMB (10MB) and MaxImportPayloadSizeChars (~2MB) reject the same import inconsistently #960

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Warning
Files:

  • src/Servy.Core/Config/AppConfig.cs lines 514, 535
  • src/Servy.CLI/Commands/ImportServiceCommand.cs line 114
  • src/Servy/Services/ServiceCommands.cs line 582
  • src/Servy.Manager/Services/ServiceCommands.cs line 667
  • src/Servy.Core/Services/XmlServiceValidator.cs line 40
  • src/Servy.Core/Services/JsonServiceValidator.cs line 40

Two separate import-size limits exist with no documented relationship and they enforce different ceilings:

public const int MaxConfigFileSizeMB    = 10;          // file-size gate (~10MB)
public const int MaxImportPayloadSizeChars = 1_024_000; // payload-char gate (~2MB UTF-16)

The CLI/desktop/manager all gate the file at 10 MB before reading. The XmlServiceValidator/JsonServiceValidator then reject anything over 1,024,000 chars (~1MB raw text, ~2MB in UTF-16 RAM). For a typical ASCII XML/JSON config:

  • A 1.5 MB file passes both gates → OK.
  • A 3 MB file passes the file-size gate, then fails the payload-char gate with XML payload exceeds the maximum allowed size of 1024000 characters. → confusing UX, the user was told the limit was 10 MB.
  • A 12 MB file is rejected by the file-size gate → consistent.

Anything in the 2–10 MB range trips a confusing two-stage rejection where the user-visible error is about the inner limit even though the outer gate advertised 10 MB.

Suggested fix (pick one):

  1. Make the file-size gate match the payload limit: MaxConfigFileSizeMB = 2 (or 1).
  2. Raise MaxImportPayloadSizeChars to ~10,000,000 to match the file gate.
  3. Document the relationship in XML doc on both constants and unify the user-visible error message so it explains both layers.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions