Skip to content

v0.23.0: stricter OData handling

Choose a tag to compare

@jaravan jaravan released this 04 Nov 22:11
· 167 commits to main since this release

What's new

A malformed URL could hang the whole server

/Set(' followed by a long run of quotes made the time to parse the path double with every pair of quotes. 56 of them took 25 seconds, and /healthz waited with it, long enough for a liveness probe to kill the pod. The same URL is now a 400 in milliseconds.

Int64 values above 2^53 hit the wrong row

PATCH Bigs(9007199254740993) changed row ...992, answered 204, and DELETE then removed it. I64 eq 9007199254740993 matched both rows. Int64 now keeps every digit in keys, $filter, $orderby, min, max, arithmetic and request bodies, on V2 and V4:

I64 add 1 eq 9007199254740994    the row ...993, and only it
{"ID":9007199254740995}          stored as ...995, not ...996

Decimals too: comparisons are exact at any length, as are add, sub, mul and mod. A quotient can't be exact, so div and divby give 15 significant digits.

A write that answered 500 but was saved

A value above U+00FF or a newline can't go in a header, so an ETag holding € or 日本 gave 500 Invalid character in header content ["ETag"], on every read of that row, and on a create that had already saved it. An ETag's non-ASCII characters, " and % are now percent-encoded, in the header and in @odata.etag:

10€  ->  W/"10%E2%82%AC"

A blank is a value

ABAP's blank is an empty string, but "" was stored as null: a Nullable="false" property couldn't be blanked (Property Description is required), and $filter=Text eq '' found nothing. "" now stays "" in a string, tells apart from null in $filter, and passes Nullable="false". A JSON data file keeps it too. A CSV cell left empty is still null, and "" for any other type is still null.

Folder names with spaces or non-ASCII characters

My Srv or Müller started normally and printed their URLs, then every request was an HTML 404. They work now, in every URL the server writes, in $batch and in @odata.bind, and the printed URLs can be pasted as they are:

V4: http://localhost:3000/odata/v4/My%20Srv/

Properties named like keywords

Div, Mod, Add, In, Or and Le gave 400 Unexpected token in $filter. True and False were read as literals, so True eq true matched every row. A word is an operator only where an operator can be:

Add add 1 eq 6
In in (5)
True eq true

UI5's V2 model without $batch

With useBatch off, UI5's V2 model sends an update as POST with X-HTTP-Method: MERGE, which answered 405 POST not allowed on an entity. X-HTTP-Method now works for PUT, PATCH, MERGE and DELETE.

Keys compare by value

Decs(1.5) was a 404 for a row stored as 1.50, and 1.5 could then be created as a duplicate. GUIDs were case-sensitive, so a key differing only in case was a second entity, and a foreign key in another case found no parent. Decs(1.5) finds 1.50, either case of a GUID finds its entity, and a duplicate is a 409.

A time is as exact as its Precision, which is all a client can read. 2025-01-01T10:00:00.123Z without a Precision reads back as 2025-01-01T10:00:00Z, and that now finds it, as a key and in $filter.

Enum literals, has and TimeOfDay

Color eq NS.Color'Red'
Perms has NS.Perm'Read,Write'
ByColors(NS.Color'Red')
hour(Tod) eq 12

By namespace or alias, by member name or value. A type or member that doesn't exist is a 400. Enum values in a write are checked against the members too.

Requests that gave a 500, or the wrong answer

  • /$count, /$value and /$ref alone: 404, not 500 Cannot read properties of undefined
  • Set(key)/$count: 400, not the whole set's count
  • Tags/$count: the collection's size, not the collection
  • Addr/$value: 400, not [object Object]
  • A system query option given twice: 400, not a 500 or the values glued together
  • $format=application/json;odata.metadata=minimal: 200, not 501
  • Dbl eq INF: finds the row
  • Deep nesting in $expand, $apply or $search: 400, not a stack overflow

$batch

  • A ? in a value no longer cuts the URL short
  • "Parent@odata.bind": "$1" names an earlier request of the changeset
  • "Parent@odata.bind": null removes a link
  • A body with no closing delimiter is a 400, and none of it runs. It used to drop the last part in silence

Stricter values

"0x10" is no longer read as 16, and a required field of a complex value is required, at any depth and in a collection (Property Addr/City is required).

Also fixed

  • A draft POST with an existing active key is a 409
  • toppercent(-5,...) is a 400
  • Properties named constructor or toString no longer store function source text
  • A schema's alias works in a bound action's name, Items(1)/Sh.Go
  • Generated keys stay inside their type: an Edm.Byte key gets 255 rows at most, a MaxLength="1" one 9
  • metadata.xml in UTF-16, as PowerShell 5.1's > writes it, loads
  • An entity set named constructor no longer stops the start

Tested with the Fiori sample apps on UI5 1.152.0, on V2 and V4, with drafts on PostgreSQL 18.6.

Upgrading

  • "" for a string is now kept as "", not null. A client or a JSON data file relying on null gets a blank, and Text eq '' no longer matches null. A blank key is still a 400
  • A system query option given twice is a 400, including ones that used to answer 200
  • $count on an entity is a 400, where it answered the set's count
  • A $batch body or a changeset with no closing delimiter is a 400
  • An enum value that isn't a member, a number written in hex, and a missing required field of a complex value are a 400. A data file with an unknown enum member stops the start
  • A PATCH replaces a complex value whole, as it did, so one that leaves out a required field is now a 400 rather than nulling it
  • A string with half a surrogate pair is a 400
  • A key with the same value as another in a different form, 1.5 and 1.50, or a GUID in another case, is a 409
  • A DateTimeOffset or TimeOfDay key without a Precision counts to the second: two in the same second are the same key
  • A V2 document's time keys without a Precision have Precision="3" in the generated V4 metadata, and show their milliseconds on V4
  • ETags holding ", % or anything but printable ASCII look different. A client holding an old one gets a 412 once
  • A number of 16 digits or more sent for a string property is accepted as text
  • A service path without its leading /, the same path for V2 and V4, or one inside the other, stops the start
  • $expand or $apply nested past 1,000 parentheses is a 400
  • Generated rows stop where the key's type does, where an Edm.Byte key with more than 255 rows used to stop the start

Install

npx odata-prova@0.23.0 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.23.0

Details

Types, Query options, Paths and options, Keys in URLs, Methods, $batch, Links between entities, ETags