rusackas commented on code in PR #42154: URL: https://github.com/apache/superset/pull/42154#discussion_r3608481756
########## superset/config.py: ########## @@ -3041,6 +3042,28 @@ class ExtraAccessQueryFilters(TypedDict, total=False): # ------------------------------------------------------------------- # Don't add config values below this line since local configs won't be # able to override them. + + +def _config_fingerprint(config_file: str | None) -> str: + """ + A short digest of the config file's bytes as read at import time. + + Auto-reloaders (e.g. werkzeug's) re-import this module when the config + file changes, and on some filesystems (notably macOS Docker mounts) the + re-read can race the write and observe stale content while still + "loading successfully". Logging the digest of what was *actually read* + makes that skew diagnosable: compare it against + ``md5 <path>`` on the host. + """ + if not config_file: + return "unknown" + try: + with open(config_file, "rb") as fh: + return hashlib.md5(fh.read()).hexdigest()[:12] # noqa: S324 Review Comment: Good catch, fixed. It reads the config bytes once now and reuses them for both `exec` and the fingerprint, so there's no second file read to race. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
