Version
opensemantic.base 0.42.8.post1000002004006.
Summary
DataToolMixin._init_archive_database treats every failure to build the
PostgREST client as recoverable: it logs a warning and falls back to a
local SQLite file. A production tool then archives to disk instead of the
time series database, and nothing in the calling code can tell.
_controller_mixin.py:
except ImportError:
_logger.warning("postgrest package not installed. Falling back to local SQLite.")
except Exception as e:
_logger.warning("Could not create PostgREST controller for %s: %s."
" Falling back to local SQLite.", db.name, e)
# Fall back to local SQLite
The if server_url: guard has the same effect by omission: when no URL
can be derived, the PostgREST branch is skipped entirely and control
falls through to the SQLite path without even a warning.
Why it triggers in a normal setup
It does not require a misconfiguration. Given
Tool.storage_locations -> [Database]
Database.server -> DatabaseServer
server is read at line 241 via db.__dict__.get("server") and then at
252 via getattr(db, "server"). Both return None, because a lazily
resolved entity comes back without its own __iris__
(OO-LD/oold-python#106). No URL is derivable, so the tool silently
archives to a local file.
Suggested fix
Make the fallback explicit rather than implicit. Something like an
allow_local_fallback flag defaulting to False, so a tool that
declares a remote storage location fails loudly when it cannot reach it,
and only an explicitly local setup writes to disk. Failing that, raise
when storage_locations names a remote database but no client could be
built.
Minor, same method
schema = getattr(server, "schema_", None) or "http"
The default contradicts the entity: our DatabaseServer declares
schema: https, and the attribute does read back as 'https' when the
server is resolved, so this is latent rather than active. But if the
attribute is ever unset the method will quietly build an http:// URL
for an https endpoint instead of reporting that the scheme is unknown.
Workaround in use
We build the PostgREST client ourselves from environment variables and
raise rather than degrade.
Version
opensemantic.base 0.42.8.post1000002004006.
Summary
DataToolMixin._init_archive_databasetreats every failure to build thePostgREST client as recoverable: it logs a
warningand falls back to alocal SQLite file. A production tool then archives to disk instead of the
time series database, and nothing in the calling code can tell.
_controller_mixin.py:The
if server_url:guard has the same effect by omission: when no URLcan be derived, the PostgREST branch is skipped entirely and control
falls through to the SQLite path without even a warning.
Why it triggers in a normal setup
It does not require a misconfiguration. Given
serveris read at line 241 viadb.__dict__.get("server")and then at252 via
getattr(db, "server"). Both returnNone, because a lazilyresolved entity comes back without its own
__iris__(OO-LD/oold-python#106). No URL is derivable, so the tool silently
archives to a local file.
Suggested fix
Make the fallback explicit rather than implicit. Something like an
allow_local_fallbackflag defaulting toFalse, so a tool thatdeclares a remote storage location fails loudly when it cannot reach it,
and only an explicitly local setup writes to disk. Failing that, raise
when
storage_locationsnames a remote database but no client could bebuilt.
Minor, same method
The default contradicts the entity: our
DatabaseServerdeclaresschema: https, and the attribute does read back as'https'when theserver is resolved, so this is latent rather than active. But if the
attribute is ever unset the method will quietly build an
http://URLfor an https endpoint instead of reporting that the scheme is unknown.
Workaround in use
We build the PostgREST client ourselves from environment variables and
raise rather than degrade.