Skip to content

booker + triage agent#24

Merged
segraef merged 9 commits intomainfrom
ns
Apr 24, 2026
Merged

booker + triage agent#24
segraef merged 9 commits intomainfrom
ns

Conversation

@segraef
Copy link
Copy Markdown
Owner

@segraef segraef commented Apr 24, 2026

Change

Feel free to remove this sample text

Thank you for your contribution !
Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context.
List any dependencies that are required for this change.

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update (Wiki)

Checklist

  • I'm sure there are no other open Pull Requests for the same update/change
  • My corresponding pipelines / checks run clean and green without any errors or warnings
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (readme)
  • I did format my code

Copilot AI review requested due to automatic review settings April 24, 2026 00:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Python utility to automatically discover and book available weekday time slots for a specific amenity (“Meeting Room 3”) using an OAuth-based login flow, and introduces basic Python setup files to support running the script.

Changes:

  • Added Python/book.py auto-booking script with OAuth login, availability discovery, and booking execution phases.
  • Added Python/requirements.txt for Python dependencies.
  • Added Python/VENV.txt with local venv usage instructions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
Python/requirements.txt Introduces Python dependency list for running scripts in Python/.
Python/book.py Implements OAuth login + amenity availability scanning and bulk booking logic with rate limiting.
Python/VENV.txt Documents how to create/use a venv and run the booking script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Python/book.py
"Content-Type": "application/json",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "en-GB,en;q=0.9,en-US;q=0.8,de;q=0.7,de-DE;q=0.6",
"Accept-Encoding": "gzip, deflate, br, zstd",
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script overrides Accept-Encoding to include br and zstd, but requests/urllib3 won’t reliably decode these encodings (especially zstd) without extra optional dependencies. This can cause resp.json()/resp.text to fail if the server honors those encodings; consider removing this header override and letting requests set a compatible default.

Suggested change
"Accept-Encoding": "gzip, deflate, br, zstd",

Copilot uses AI. Check for mistakes.
Comment thread Python/book.py
Comment on lines +299 to +303
resp = session.post(f"{BASE_URL}{path}", params=params, json=payload)
if resp.status_code == 401:
print(" 🔐 Session expired, signing in again...")
login(session)
resp = session.post(f"{BASE_URL}{path}", params=params, json=payload)
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Network calls are made without a timeout (e.g., this session.post), which can cause the script to hang indefinitely on network issues. Add a reasonable default timeout (and possibly separate connect/read timeouts) to all get/post calls.

Copilot uses AI. Check for mistakes.
Comment thread Python/book.py
if resp.status_code != 200:
print(f" ⚠️ slot check returned {resp.status_code}, backing off {DELAY_ON_ERROR}s")
pause(DELAY_ON_ERROR)
return {}
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On non-200 responses get_slots() returns {}, and callers treat missing keys as “unavailable”, making transient API errors look like “fully booked already” and hiding failures. Return a distinct sentinel (e.g., None) or raise/propagate an error so the calling loop can retry/skip explicitly.

Suggested change
return {}
resp.raise_for_status()

Copilot uses AI. Check for mistakes.
Comment thread Python/book.py
Comment on lines +476 to +480
# Ask user how many days to scan
if not args.yes:
print(f"\n📆 How far ahead do you want to scan for available slots?")
print(f" 1) Last 1 week (faster, ~{min(7, avail_days)}d)")
print(f" 2) Last 2 weeks (~{min(14, avail_days)}d)")
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prompt asks “How far ahead do you want to scan”, but the implementation scans the last portion of the platform window (ending at max_end), which can miss near-term availability when selecting 1–2 weeks. Consider scanning forward from today up to min(today + scan_days, max_end) to match the prompt.

Copilot uses AI. Check for mistakes.
Comment thread Python/book.py
Comment on lines +282 to +284
raise RuntimeError(
"OAuth token cookie missing after token exchange. "
f"Response was: {token_resp.text[:300]}"
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On OAuth token-cookie failures this error includes a slice of token_resp.text, which may contain sensitive token material and leak credentials into logs/terminals. Redact sensitive fields or log only non-secret diagnostics (status code, request id, etc.).

Suggested change
raise RuntimeError(
"OAuth token cookie missing after token exchange. "
f"Response was: {token_resp.text[:300]}"
request_id = (
token_resp.headers.get("X-Request-ID")
or token_resp.headers.get("X-Correlation-ID")
or token_resp.headers.get("Request-Id")
or "n/a"
)
raise RuntimeError(
"OAuth token cookie missing after token exchange. "
f"Status: {token_resp.status_code}. Request ID: {request_id}"

Copilot uses AI. Check for mistakes.
Comment thread Python/book.py
Comment on lines +490 to +491
# Always end at the platform maximum; start is max_end - scan_days (but no earlier than today)
scan_start = max(today, max_end - timedelta(days=scan_days))
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off-by-one: scan_start = max_end - timedelta(days=scan_days) combined with an inclusive while d <= end loop means you scan scan_days + 1 calendar days. Adjust the start/end computation (or make the loop end-exclusive) so the selected window length matches what’s displayed/expected.

Suggested change
# Always end at the platform maximum; start is max_end - scan_days (but no earlier than today)
scan_start = max(today, max_end - timedelta(days=scan_days))
# Always end at the platform maximum; because weekdays_in_range is end-inclusive,
# start must be max_end - (scan_days - 1) to scan exactly scan_days calendar days
# (but no earlier than today).
scan_start = max(today, max_end - timedelta(days=scan_days - 1))

Copilot uses AI. Check for mistakes.
@segraef segraef changed the title Ns booker + triage agent Apr 24, 2026
segraef and others added 5 commits April 24, 2026 13:33
@segraef segraef merged commit d039a2e into main Apr 24, 2026
1 of 2 checks passed
@segraef segraef deleted the ns branch April 24, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants