Skip to content

[Bug]: Autoentities generates invalid REST paths for tables with spaces in their names #3595

@JerryNixon

Description

@JerryNixon

Expected

When autoentities discovers a table with a space in its name (e.g., Order Items), the generated entity name should be sanitized to produce a valid URL path — or dab auto-config should warn the user before generating the config.

Actual

dab validate fails with:

fail: The rest path: dbo_Order Items for entity: dbo_Order Items contains whitespace which is not allowed in URL paths.
fail: Config is invalid.

The {schema}_{object} name pattern passes the space through verbatim, producing /api/dbo_Order Items, which is an invalid URL path. The user must manually add an exclude pattern to work around this.

Suggestion

Replace spaces (and other URL-unsafe characters) in the interpolated entity name with a safe delimiter. For example, if the name pattern is {schema}_{object}, transform dbo_Order Itemsdbo_OrderItems or dbo_Order_Items before assigning the REST path. This matches how the engine already validates the final name — it should sanitize, not just reject.

static string SanitizeEntityName(string name)
{
    var sb = new StringBuilder(name.Length);
    bool capitalizeNext = false;

    foreach (char c in name)
    {
        if (char.IsWhiteSpace(c))
        {
            capitalizeNext = true;
            continue;
        }

        sb.Append(capitalizeNext ? char.ToUpperInvariant(c) : c);
        capitalizeNext = false;
    }

    return sb.ToString();
}

"dbo_Order Items""dbo_OrderItems"

Metadata

Metadata

Type

Projects

Status

Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions