Files
gnucash/libgnucash
Noerr 5d5cd0b758 [engine] gnc_price_set_source_string: warn on an unknown source string
The setter maps a fixed set of canonical strings (source_names) to the
PriceSource enum. On any other string it fell through the loop and returned
having changed nothing -- silently -- so callers on the XML and SQL load paths,
the GUI price editor, and (until deprecated) the bindings got no indication that
the source was dropped. Emit a PWARN so an unrecognized source string is at least
visible in the log instead of vanishing.

Kept at WARNING rather than CRITICAL: this setter is primarily a deserialization
helper fed stored data, so an unrecognized string is unexpected external data,
not a broken precondition. A garbage source in a SQL backend -- for which there
is no repair path -- should not log a CRITICAL on every open; the price still
loads and only its source label degrades to PRICE_SOURCE_INVALID.

"invalid", the string form of PRICE_SOURCE_INVALID, reaches this fall-through as
well. INVALID is only the loop sentinel, never a settable source, so it is warned
uniformly like any other non-settable string. This is a real, non-corrupt case:
the random-price test generator and existing books both hold PRICE_SOURCE_INVALID
prices that serialize as "invalid" and round-trip back through here.

The warning names the offending price -- commodity namespace:mnemonic -> currency
mnemonic and its date -- so a user who finds it in the trace log has enough to
locate the price in the price editor and correct or remove it. The commodity,
currency and date are already populated when the source is set on both load
paths (the SQL col_table and the XML element order both place source last).
2026-09-26 13:50:55 -07:00
..