-
Notifications
You must be signed in to change notification settings - Fork 56
Bug-Squash/'Works-on-my-machine' - 4 PRDs in one PR :( 👎 #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
400e500
8e73c04
27f74b7
b2800ca
2129647
ccd63bf
96adaac
bc49d4c
48f9795
8d3026d
4c4e8bf
18bea9c
f3f7ad6
5439691
7f93757
90e527e
9763ca2
13d1030
ffd1c7b
a18f8e6
9063223
f5ec492
a5d3ef5
1c9903c
4a53e49
da7ad02
bfc8aae
1486e6d
45ebef0
b93b11d
a6afe1f
349db3d
2245814
00f1036
a9d62ce
066917c
0d66be8
e6a36f6
79f888f
96ebea9
9d84bec
ee86363
8f687b5
3c4abe7
599c624
3e36a12
a5e8e71
bced400
9972090
9e1a1f4
89c9ca7
c646195
bd9f956
f0a84ab
e6c46b2
55a4e9c
c78b84c
069fcee
24f56a0
4e6702c
33f1784
c14a69b
ed6319a
a78f177
8f08b9e
c6b2457
ff9ff41
566d459
aa89995
445c358
bd4cffc
32cd014
0bab803
6029568
120a414
131f9de
0dd9626
54ecd44
5b571fd
929c5ef
654828b
c289fa5
52b938e
e66993d
1ac6b84
06f5990
846fbe2
d5e88c9
4c974d4
a6d4ee7
63d9177
04f0d25
65341b4
f15c87d
ce8dc64
8248dab
3fc692f
71b1942
ad82dfd
7383a85
c83067a
a323328
acf9eac
b1f242e
d7a9510
de1795d
3e97878
bb7c863
cbfbfe5
51d69a7
bdc05dd
87e36bf
3f72df3
34f415f
b3fb41d
048239a
1913084
5cdccf9
b89f1c2
e793bf0
7dfd54f
ffb5b18
e4a3046
5bde366
4a0f332
c74b53d
cfc9b73
b311945
f3cbe53
8edcaf4
dd49bf4
6361039
ed8407d
8606329
6e27b9a
0fe8518
2e63935
c21cd15
9e59bb1
5986489
1b6642a
d607229
46f40d1
2be045c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,8 @@ jobs: | |
| TEST_DB_HOST: 127.0.0.1 | ||
| TEST_DB_USER: tldw | ||
| TEST_DB_PASSWORD: tldw | ||
| # Align AuthNZ_Postgres conftest default DB name with service DB | ||
| TEST_DB_NAME: tldw_content | ||
| TLDW_TEST_POSTGRES_REQUIRED: '1' | ||
| steps: | ||
| - name: Checkout | ||
|
|
@@ -115,6 +117,9 @@ jobs: | |
| run: | | ||
| echo "POSTGRES_TEST_PORT=${{ job.services.postgres.ports[5432] }}" >> "$GITHUB_ENV" | ||
| echo "TEST_DB_PORT=${{ job.services.postgres.ports[5432] }}" >> "$GITHUB_ENV" | ||
| # Provide a unified DSN so any test preferring TEST_DATABASE_URL uses the right DB | ||
| echo "TEST_DATABASE_URL=postgresql://tldw:[email protected]:${{ job.services.postgres.ports[5432] }}/tldw_content" >> "$GITHUB_ENV" | ||
| echo "DATABASE_URL=postgresql://tldw:[email protected]:${{ job.services.postgres.ports[5432] }}/tldw_content" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Install additional deps for PG tests | ||
| run: | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -777,6 +777,10 @@ async def ttl_sweep_endpoint( | |
| user=Depends(require_admin), | ||
| ) -> TTLSweepResponse: | ||
| try: | ||
| # Correlation IDs and diagnostics | ||
| from tldw_Server_API.app.core.Logging.log_context import get_ps_logger, ensure_request_id, ensure_traceparent | ||
| rid = ensure_request_id(request) | ||
| tp = ensure_traceparent(request) | ||
|
Comment on lines
+867
to
+870
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused variable. The variable Apply this diff: - from tldw_Server_API.app.core.Logging.log_context import get_ps_logger, ensure_request_id, ensure_traceparent
rid = ensure_request_id(request)
- tp = ensure_traceparent(request)Or, if tracing correlation is desired: try:
- get_ps_logger(request_id=rid, ps_component="endpoint", ps_job_kind="jobs").info(
- "TTL sweep request: action=%s domain=%s queue=%s job_type=%s age=%s runtime=%s backend=%s ref_now=%s",
+ get_ps_logger(request_id=rid, traceparent=tp, ps_component="endpoint", ps_job_kind="jobs").info(
+ "TTL sweep request: action=%s domain=%s queue=%s job_type=%s age=%s runtime=%s backend=%s ref_now=%s",
req.action, req.domain, req.queue, req.job_type, req.age_seconds, req.runtime_seconds, (backend or "sqlite"), str(ref_now) if ref_now else ""
)
🧰 Tools🪛 Ruff (0.14.3)839-839: Local variable Remove assignment to unused variable (F841) 🤖 Prompt for AI Agents |
||
| # Pre-parse raw to enforce RBAC and confirm header before validation | ||
| try: | ||
| raw = await request.json() | ||
|
|
@@ -805,20 +809,43 @@ async def ttl_sweep_endpoint( | |
| jm = JobManager(backend=backend, db_url=db_url) | ||
| # Now validate the request model | ||
| req = TTLSweepRequest(**(raw or {})) | ||
| # Capture a single reference time to avoid boundary drift between age/runtime calculations | ||
| try: | ||
| from datetime import datetime, timezone as _tz | ||
| ref_now = datetime.now(tz=_tz.utc) | ||
| except Exception: | ||
| ref_now = None | ||
| # Diagnostics before executing | ||
| try: | ||
| get_ps_logger(request_id=rid, ps_component="endpoint", ps_job_kind="jobs").info( | ||
| "TTL sweep request: action=%s domain=%s queue=%s job_type=%s age=%s runtime=%s backend=%s ref_now=%s", | ||
| req.action, req.domain, req.queue, req.job_type, req.age_seconds, req.runtime_seconds, (backend or "sqlite"), str(ref_now) if ref_now else "" | ||
| ) | ||
| except Exception: | ||
| pass | ||
| affected = jm.apply_ttl_policies( | ||
| age_seconds=req.age_seconds, | ||
| runtime_seconds=req.runtime_seconds, | ||
| action=req.action, | ||
| domain=req.domain, | ||
| queue=req.queue, | ||
| job_type=req.job_type, | ||
| reference_time=ref_now, | ||
| ) | ||
| # Refresh gauges when fully scoped to avoid stale metrics | ||
| try: | ||
| if req.domain and req.queue and req.job_type: | ||
| jm._update_gauges(domain=req.domain, queue=req.queue, job_type=req.job_type) | ||
| except Exception: | ||
| pass | ||
| # Diagnostics after executing | ||
| try: | ||
| get_ps_logger(request_id=rid, ps_component="endpoint", ps_job_kind="jobs").info( | ||
| "TTL sweep result: affected=%s action=%s domain=%s queue=%s job_type=%s", | ||
| int(affected), req.action, req.domain, req.queue, req.job_type | ||
| ) | ||
| except Exception: | ||
| pass | ||
| return TTLSweepResponse(affected=int(affected)) | ||
| except HTTPException: | ||
| raise | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.