Repository navigation
Conversation
…DEBUG TAP_DEBUG was an all-or-nothing server env var — turning it on wrote debug files for every archive on the host. We needed per-archive control so each deployment can opt in independently via its own TAP.conf. configparam reads DEBUG from [WEB] and exposes it as debug_flag. Only the string '1' enables it, same strictness as TAP_DEBUG. compat adds DEBUG to _WEB_KEYS so existing 1.x configs with [webserver] DEBUG keep working after upgrade without needing a manual edit.
…DEBUG=1 TAP_DEBUG=1 used to call logging.basicConfig(filename=...) on startup, so a debug file appeared for every archive before the config was even read. If TAP.conf was missing or broken, a file was still created. Now TAP_DEBUG buffers log records in memory until the config loads. If DEBUG=1 in that archive's TAP.conf the buffer replays into the file. If the config says DEBUG=0 the buffer is discarded. If config loading fails, the buffer flushes to stderr (web server error log) instead — no file. Also removed debug=1 hardcoded at six call sites that were switching debug on regardless of what the config said. The leftover **kwargs on __executeSql__ from that cleanup was removed too.
The debug file must only appear when the archive's TAP.conf says DEBUG=1. TAP_DEBUG alone must never create one, and a failed config load must not either. These tests nail down those boundaries so they don't regress quietly. Covers the four TAP_DEBUG/DEBUG combinations, what ends up in the file vs stderr, the 1.x config migration path, and that a form field in a request can't turn debug on. clean_root_logger in conftest.py tears down any handlers Tap attaches so tests don't bleed into each other.
Added a Debug Logging section to configure.rst. Operators would have no way to know the DEBUG key exists otherwise. configure.rst was referring to the env var as TAP_CONFIG. The correct name is TAP_CONF. Easy to miss when you're looking for the wrong thing. MIGRATING.md left DEBUG out of the 1.x-to-3.x key table, making it look like it wasn't carried forward on upgrade. Added a commented DEBUG=0 line to TAP.conf and the test fixture so the key is discoverable without reading the source.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TAP_DEBUG=1was the only way to enable debug logging. Setting it on the server wrote a debug file for every archive on the host, before the config was even read. IfTAP.confwas missing or broken, a file still appeared in/tmp. There was no way to turn debug on for one archive and not another.There were also six places in the code that passed
debug=1hardcoded, so those code paths always ran in debug mode regardless of what the config said.What this does
Each archive now controls debug via its own
TAP.conf:The
/tmp/tap_<pid>.debugfile is only created after the config loads and confirmsDEBUG = 1for that archive. Only the string1turns it on.TAP_DEBUG=1still works but is now a startup diagnostic only. It buffers log records in memory until the config loads. If the config saysDEBUG = 1, those early records get written into the debug file. If the config saysDEBUG = 0, they are discarded. If the config fails to load at all (missing file, bad format), the buffer goes tostderr(the web server error log) instead of creating a/tmpfile.Archives still on the 1.x
[webserver]layout getDEBUGtranslated to[WEB]automatically on read, same as the other keys.The six hardcoded
debug=1kwargs were replaced withdebug=self.debugor removed where the callee ignores the argument.Tests
29 regression tests in
tests/test_debug_policy.py. They cover all four combinations ofTAP_DEBUGandconfig DEBUG, the pre-config failure path (buffer to stderr, no file created), config parsing edge cases, and that a form field in a request cannot enable debug. The 1.x migration path has its own test intest_compat_config.py.Upgrading
Debug is off by default. Existing deployments do not need to change anything.
To enable debug for an archive, add
DEBUG = 1to its[WEB]section. If you were usingTAP_DEBUG=1to get per-request debug files, useDEBUG = 1inTAP.confinstead.TAP_DEBUGno longer writes files.