Skip to content

Conversation

@Prateekiiitg56
Copy link

@Prateekiiitg56 Prateekiiitg56 commented Feb 6, 2026

PR Description

Summary

This PR delivers a Git-based storage adapter for immutable, versioned patient records (commit-per-save) and integrates it into a Flask “minimalist monolith” web app with upload/history/diff views. It also updates the UI to a consistent Alaska/aurora theme across all pages with a project-relevant navbar and this is just prototype like a quick view of how the overall theme will gonna be.Every feature is only listed for now ,they can be enhanced and be for efficient later.

Key Features

Git-backed storage (bhv/storage/git_adapter.py)

  • Commit-per-save versioning for uploaded files
  • History listing and content retrieval by commit SHA
  • Conflict handling support (parent mismatch)

Flask app flow (bhv/full_app.py)

  • / always renders the homepage (no redirect after login)
  • /dashboard routes signed-in users to entries/admin appropriately
  • Upload flow persists:
    • narrative metadata in DB
    • file bytes in Git storage
  • Optional request debug logging gated behind BHV_REQUEST_DEBUG=1

Security / Auth

  • CSRF protection enabled via Flask-WTF
  • Upload form fixed to render CSRF token as a hidden input (no token shown on page)
  • Google sign-in client id exposed to templates via app.config['GOOGLE_CLIENT_ID']
  • Session cookie secure behavior configurable via SESSION_COOKIE_SECURE

UI/UX (templates/* + static/css/alaska.css)

  • Global Alaska background and glass navbar styling across all pages
  • Project-focused nav items: Home / Upload / Entries + Profile
  • Sticky footer behavior for short pages
bhv1 bhv2 bhv3

…nd templated UI

- Add run.py: single-command app launcher
- Implement bhv/db.py: MongoDB + TinyDB fallback DB abstraction
- Implement bhv/full_app.py: minimal Flask app with routes for signup, login, logout, upload, my_entries, admin, history, diff, file_version
- Add templates: base.html (header/nav/footer), index.html, signup.html, login.html, upload.html, patient.html (my entries), admin.html, history.html, diff.html
- Add static/css/alaska.css: Alaska-themed design (teal accents, minimal cards, responsive layout)
- Update requirements.txt: add TinyDB for embedded DB fallback
- Templates support Bootstrap-like card layout with forms and file listings
- Routes support role-based access control (patients view own entries, admins see all)
- Storage integration: uses GitAdapter for versioned commits per file save
- Add flask-wtf CSRF protection to all forms
- Implement email validation and password strength check (min 6 chars)
- Add Google OAuth endpoint (/auth/google) for user auto-creation and login
- Add Google Sign-In button to login and signup pages using Google Identity Services
- Set secure session cookie flags (HttpOnly, SameSite, Secure in production)
- Add persistent session management (7-day lifetime)
- Update signup/login to handle OAuth and email-based auth seamlessly
- Add .env.example with documentation for GOOGLE_CLIENT_ID and MONGO_URI
Copilot AI review requested due to automatic review settings February 6, 2026 22:13
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Prateekiiitg56, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers a significant upgrade to the application by introducing a robust Git-backed storage system for managing immutable, versioned patient records. It integrates this new storage into a fully functional Flask web application, complete with user authentication, file upload capabilities, and detailed version history and diff views. The user interface has been completely revamped with a modern, consistent theme, and several security enhancements have been implemented to ensure data integrity and user protection.

Highlights

  • Git-backed Storage Adapter: Introduced a new Git-based storage adapter (bhv/storage/git_adapter.py) for immutable, versioned patient records, supporting commit-per-save, history listing, content retrieval by commit SHA, and conflict handling.
  • Flask Web Application: Developed a comprehensive Flask web application (bhv/full_app.py) that integrates the Git storage, providing routes for user authentication (signup, login, Google OAuth), file upload, viewing entry history, and diffing between versions.
  • Unified UI/UX Theme: Implemented a consistent 'Alaska/aurora' theme across all pages, featuring a new global background, glass navbar styling, project-focused navigation, and a sticky footer, enhancing the overall user experience.
  • Enhanced Security Features: Integrated CSRF protection via Flask-WTF, fixed upload forms to correctly render CSRF tokens, and enabled configurable secure session cookie behavior, improving the application's security posture.
  • Database Abstraction: Created a flexible database layer (bhv/db.py) that can utilize MongoDB for persistence or fall back to TinyDB for zero-setup deployments, managing user and entry metadata.
  • Comprehensive Documentation and Testing: Added detailed READMEs for the application and Git adapter, along with new integration and unit tests (tests/*) to ensure the stability and correctness of the new features and UI.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .env.example
    • Added example environment variables for Flask configuration, MongoDB, and Google OAuth.
  • README_APP.md
    • Added a comprehensive README detailing features, quick start, project structure, configuration, API routes, security notes, testing, and development guidelines.
  • README_GIT_ADAPTER.md
    • Added a README specific to the Git-backed storage adapter, explaining its key ideas and how to test it locally.
  • bhv/init.py
    • Added __all__ declaration for app and storage.
  • bhv/app.py
    • Added a standalone Flask app for the Git storage adapter demo, including routes for upload, history, file retrieval, and diffing, with conflict handling.
  • bhv/db.py
    • Implemented a database abstraction layer supporting MongoDB (if MONGO_URI is set) or TinyDB as a fallback.
    • Added functions for user and entry management (create, get, list, update, delete).
  • bhv/full_app.py
    • Implemented create_app function for app factory pattern, supporting testing and configurable upload folders.
    • Integrated session management, CSRF protection, and optional request debug logging.
    • Added Google OAuth for sign-in functionality.
    • Defined routes for user authentication (signup, login, logout), file management (upload, my entries, admin entries), and versioning (history, diff, file download).
    • Included logic for handling patient vs. admin roles and access control.
    • Utilized GitAdapter for file storage and difflib for showing file differences.
  • bhv/storage/base.py
    • Defined an abstract StorageAdapter class with methods for save, save_with_parent, get, history, and head.
  • bhv/storage/errors.py
    • Defined a custom Conflict exception for optimistic locking scenarios.
  • bhv/storage/git_adapter.py
    • Implemented the GitAdapter class, providing Git-backed storage for patient records.
    • Each patient gets a separate Git repository, and each save creates a commit with metadata.
    • Included optimistic locking with save_with_parent to prevent concurrent modification issues.
  • data/db.json
    • Added initial TinyDB data with example user accounts (patient and admin).
  • pytest.ini
    • Added pytest configuration for test discovery and options.
  • requirements.txt
    • Added new dependencies: Flask, GitPython, pymongo, python-dotenv, flask-wtf, flask-oauthlib, google-auth-oauthlib, pytest, tinydb.
  • run.py
    • Added the main entry point for the Flask application, loading environment variables and running the app.
  • scripts/check_cffi.py
    • Added a script to check CFFI and cryptography imports, useful for debugging environment issues.
  • scripts/demo_run.py
    • Added a script to demonstrate the Git-backed storage adapter's functionality using the Flask test client, covering upload, update with parent, history, and diff.
  • scripts/make_screenshots.py
    • Added a script to run the demo and generate PNG screenshots of the console output for documentation.
  • static/css/alaska.css
    • Added a new CSS file for the 'Alaska' theme, defining a consistent UI/UX with a new color palette, typography, layout, and responsive design.
  • static/img/alaska-3d.svg
    • Added an SVG image for a 3D Alaska-themed graphic.
  • static/img/alaska-logo.svg
    • Added an SVG image for the Alaska BHV logo.
  • static/img/favicon.svg
    • Added an SVG image for the favicon.
  • static/img/hospital-icon.svg
    • Added an SVG image for a hospital icon.
  • templates/admin.html
    • Added a new template for the admin dashboard to view all entries.
  • templates/base.html
    • Updated the base template to include the new Alaska theme, project-relevant navbar, and sticky footer.
  • templates/contact.html
    • Added a placeholder contact page.
  • templates/diff.html
    • Added a new template to display unified diffs between file versions.
  • templates/features.html
    • Added a placeholder features page.
  • templates/history.html
    • Added a new template to display the commit history for a file, with links to download specific versions and view diffs.
  • templates/home.html
    • Added a new home page template with a hero section and key feature highlights.
  • templates/how_it_works.html
    • Added a placeholder 'How It Works' page.
  • templates/index.html
    • Added a basic welcome page with signup/login links.
  • templates/login.html
    • Added a login page with email/password and Google Sign-In options.
  • templates/patient.html
    • Added a template for patients to view their own entries.
  • templates/profile.html
    • Added a profile page displaying user information and recent entries.
  • templates/signup.html
    • Added a signup page with email/password and Google Sign-In options, and role selection.
  • templates/testimonials.html
    • Added a placeholder testimonials page.
  • templates/upload.html
    • Added an upload form with file and narrative input, including CSRF token.
  • tests/test_app_integration.py
    • Added integration tests for the bhv.app module, covering upload, history, and conflict handling.
  • tests/test_full_app.py
    • Added integration tests for the full Flask application flow, including signup, login, upload, history, versioning, diff, admin access, and patient access control.
  • tests/test_git_adapter.py
    • Added unit tests for the GitAdapter, covering save, history, and optimistic locking conflict scenarios.
Activity
  • The pull request introduces a new Git-backed storage system, indicating a significant architectural change to how patient records are managed.
  • A complete Flask web application has been developed to expose this new storage functionality through a user-friendly interface.
  • The UI has undergone a major overhaul, adopting a new 'Alaska' theme for a modern and consistent look and feel.
  • New security measures, including CSRF protection and Google OAuth integration, have been implemented.
  • Extensive new test files have been added, demonstrating a commitment to code quality and ensuring the reliability of the new features.
  • Detailed documentation, including comprehensive READMEs and demo scripts, has been provided to facilitate understanding and usage of the new system.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is a substantial pull request that introduces a complete backend with a Git-based storage adapter and a new frontend UI. The overall architecture is well-thought-out, with a clear separation of concerns between the web app, database layer, and storage adapter. The use of a database abstraction layer and an abstract storage adapter class are great design choices. My review focuses on improving robustness, security, and maintainability. I've identified a few critical issues, such as a security risk with a committed data file, a CSS syntax error, and a missing import that would cause a runtime error. I've also provided suggestions to handle exceptions more gracefully, clean up dependencies, and improve the clarity of tests and documentation. Overall, this is a very impressive feature addition. Addressing these points will help make the application more secure and reliable.

@@ -0,0 +1 @@
{"users": {"1": {"email": "test@example.com", "password": "scrypt:32768:8:1$rzJQOnK6yDTD29gZ$6d4e6acea9e3f7a746a3778c056ea7a8f2af90b20dd2723c99ae28142a062c3503b1e04d407c5280b847d35b57007ceef053898c92852f135d901c9d14076ea9", "role": "patient"}, "2": {"email": "patient@example.com", "password": "scrypt:32768:8:1$PkIL3lc7IsiuD59w$3e961f57b0a0a75a4f17e20dd05642d867f39d8cb992fd717c77fe80a1e3c8677b8132510edd1de913675bc76ccfb6411f9c3c38b729f4ddb4f3b6f6738d6977", "role": "patient"}, "3": {"email": "version@example.com", "password": "scrypt:32768:8:1$EWcPmYC38oGXFHBO$e303115b424697d6efe369b640af249bf8d66581041142a7ddeb686fc9af03b47d0c576e689542b4a1f8b6fd71a562afdd70948642c49a8102d506a252a17d6b", "role": "patient"}, "4": {"email": "download@example.com", "password": "scrypt:32768:8:1$mml5O8EzrxcBgURY$172bfeb3ac63eee926dc0597f7632f40341968dc9bd90a004b631b4bda3e2aba6bb90cd071d80af91c9c17ce77d0e497d73b839a35244c28db8c3aa56e7bd1e0", "role": "patient"}, "5": {"email": "admin@example.com", "password": "scrypt:32768:8:1$G8pXchlCpNjOySdM$d045220f7c8e2289b8749008a84bf44125049cbcea7933a39d25dbb549d103639df3ac2c0dae29e941d091dbb302b16d02afa8d90bb7a9a05f3934b3c33e43bd", "role": "admin"}, "6": {"email": "patient1@example.com", "password": "scrypt:32768:8:1$vWFvVhBvXKMgg6ig$5c88706d61af51be5bddcc5fe832573b8602a59163f6e60555522a18478a5c95b6e3b305820273d69e64e6508bb64ece90420323d5220cdeca22171efcc7c853", "role": "patient"}, "7": {"email": "patient2@example.com", "password": "scrypt:32768:8:1$CQFRHKENYhy8fBq1$a633880009710c203eaf4dfb783a1da44ff54a24bba23277be40fdbdedb96e7350e3b4a98ebd6c823355feed7a959bab51a0879762346fa287d6e9691298401c", "role": "patient"}, "8": {"email": "ps332927@gmail.com", "password": "", "role": "patient"}, "9": {"email": "prateek.singh23b@iiitg.ac.in", "password": "", "role": "patient"}, "10": {"email": "smoke@example.com", "password": "scrypt:32768:8:1$jaupQ6ucydydcpHJ$4c0345798909ddbef3d89ac9029e694cb17bb53c97baac8a7172893d99a0dc823292e5d97d0e7adf447b2ba12a507341a5cef088a57f67e256685600c940ffa6", "role": "patient"}}} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

security-critical critical

This file contains sensitive data, including user emails and hashed passwords. Committing such a file to version control, even with test data, is a significant security risk. It exposes user information and password hashes to anyone with access to the repository's history. This file should be removed from the repository and added to .gitignore to prevent accidental commits in the future.

Comment on lines +141 to +151
color: rgba(255,255,255,0.88);
color: var(--text-secondary);
text-decoration: none;
padding: 6px 0;
border-bottom: 2px solid transparent;
transition: all 0.2s ease;
}

color: rgba(255,255,255,0.98);
border-bottom-color: rgba(255,255,255,0.55);
border-bottom-color: var(--accent-teal);
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

There are a couple of issues in this block:

  1. The color property is set twice (lines 141 and 142). The second one will always override the first.
  2. The rules on lines 149-151 are outside of any CSS selector, which is a syntax error. They will be ignored by the browser. These rules might belong inside a pseudo-class selector like :hover for .site-nav a.
  3. border-bottom-color is declared twice on lines 150 and 151.

@@ -0,0 +1,350 @@
import os
import re
from flask import Flask, render_template, request, redirect, url_for, session, send_from_directory, flash
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The Response class is used on line 347 but is not imported from flask. This will cause a NameError at runtime. Please add it to the import statement.

Suggested change
from flask import Flask, render_template, request, redirect, url_for, session, send_from_directory, flash
from flask import Flask, render_template, request, redirect, url_for, session, send_from_directory, flash, Response

return list(db.entries.find())

def get_entry(entry_id):
from bson import ObjectId
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Importing ObjectId within a function is inefficient and not standard practice. This import should be moved to the module level, inside the if MONGO_URI: block (e.g., at line 7), to be imported only once. This applies to the same import on lines 40 and 44.

flash('File required')
return redirect(url_for('upload'))
filename = secure_filename(f.filename)
patient_id = user.get('email') if user.get('role')=='patient' else request.form.get('patient_id')
Copy link
Contributor

Choose a reason for hiding this comment

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

high

If an admin user submits the upload form without providing a patient_id, request.form.get('patient_id') will return None. This will cause os.path.join(patient_id, filename) on the next line to raise a TypeError. You should add a check to ensure patient_id is present for admin uploads.

Suggested change
patient_id = user.get('email') if user.get('role')=='patient' else request.form.get('patient_id')
patient_id = user.get('email') if user.get('role')=='patient' else request.form.get('patient_id')
if user.get('role') == 'admin' and not patient_id:
flash('Patient ID is required for admin uploads.')
return redirect(url_for('upload'))

session.permanent = True
session['user_email'] = email
return redirect(url_for('index'))
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Catching a broad Exception can hide underlying issues and make debugging difficult. It's better to catch the specific exceptions that id_token.verify_oauth2_token can raise, such as ValueError for an invalid token.

Suggested change
except Exception as e:
except ValueError as e:

new_bytes = storage.get(rel, new_sha)
try:
old_text = old_bytes.decode('utf-8').splitlines()
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Catching a broad Exception here can mask the actual problem. It's better to catch the specific UnicodeDecodeError that can occur during decoding. This would make the error handling more precise.

Suggested change
except Exception:
except UnicodeDecodeError:

# HEAD references it.
try:
_ = repo.head.commit.hexsha
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Catching a broad Exception can hide unexpected errors and make debugging more difficult. It's better to catch more specific exceptions that GitPython might raise, such as git.exc.GitCommandError. This applies to other broad except blocks in this file as well (e.g., lines 59, 84, 117, 139).

pymongo>=4.0
python-dotenv>=0.21
flask-wtf>=1.0
flask-oauthlib>=0.9
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The flask-oauthlib library is included as a dependency, but it appears to be unused in the project. This library is also considered outdated and is unmaintained. It should be removed to keep the project's dependencies clean and avoid potential security vulnerabilities from unmaintained packages.

Comment on lines +37 to +41
try:
adapter.save_with_parent(rel, b'three', user_id='u3', action='edit', parent='deadbeef')
assert False, "Expected conflict"
except Conflict:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While this try/except block works for testing that an exception is raised, the idiomatic way to test for exceptions with pytest is to use the pytest.raises context manager. This makes the test more concise and clearly states the intent.

Suggested change
try:
adapter.save_with_parent(rel, b'three', user_id='u3', action='edit', parent='deadbeef')
assert False, "Expected conflict"
except Conflict:
pass
from bhv.storage.errors import Conflict
import pytest
with pytest.raises(Conflict):
adapter.save_with_parent(rel, b'three', user_id='u3', action='edit', parent='deadbeef')

Copy link

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 Git-backed, commit-per-save storage adapter and integrates it into a Flask “minimalist monolith” with upload/history/diff views, along with a new Alaska-themed UI and initial test coverage.

Changes:

  • Introduce GitAdapter + storage interface/exceptions for versioned file storage.
  • Add/expand Flask app routes for auth, upload, entries, history, diff, and download; add templates + Alaska CSS/theme assets.
  • Add pytest config and multiple unit/integration tests; add demo/screenshot scripts and documentation.

Reviewed changes

Copilot reviewed 35 out of 44 changed files in this pull request and generated 31 comments.

Show a summary per file
File Description
tests/test_git_adapter.py Unit tests for GitAdapter save/history/conflict behavior
tests/test_full_app.py Integration tests for Flask full app flows
tests/test_app_integration.py Integration tests for the legacy/demo API app (bhv.app)
templates/base.html Global layout + navbar/footer
templates/home.html Themed homepage hero + highlights section
templates/index.html Simple landing page template (may be legacy)
templates/signup.html Signup page + Google sign-in
templates/login.html Login page + Google sign-in
templates/upload.html Upload form with CSRF token hidden input
templates/patient.html Patient entries list + download/delete actions
templates/admin.html Admin entries list + download/delete actions
templates/profile.html Profile view with recent files
templates/history.html History view with per-commit download + diff links
templates/diff.html Unified diff display
templates/features.html Informational page
templates/how_it_works.html Informational page
templates/testimonials.html Informational page
templates/contact.html Informational page
static/css/alaska.css New Alaska/aurora theme styling
static/img/favicon.svg App favicon
static/img/alaska-logo.svg Navbar/logo asset
static/img/alaska-3d.svg Decorative asset
static/img/hospital-icon.svg Decorative icon asset
scripts/demo_run.py Demo script to exercise upload/history/diff
scripts/make_screenshots.py Generates screenshots from demo output
scripts/check_cffi.py Diagnostic script for cffi/cryptography environment
scripts/screenshots/initial_and_edit.png Generated screenshot artifact
scripts/screenshots/history.png Generated screenshot artifact
scripts/screenshots/diff.png Generated screenshot artifact
bhv/storage/base.py StorageAdapter interface
bhv/storage/errors.py Conflict exception type
bhv/storage/git_adapter.py Git-backed storage implementation
bhv/db.py MongoDB/TinyDB abstraction for users/entries
bhv/app.py Legacy/demo API app using GitAdapter
bhv/full_app.py Main Flask app factory + routes (auth/upload/history/diff/download)
bhv/init.py Package marker/exports
run.py Entry point to run the full app
requirements.txt Runtime + test dependencies
pytest.ini Pytest configuration
data/db.json TinyDB data file (currently populated)
README_GIT_ADAPTER.md Git adapter documentation
README_APP.md Full app documentation
.env.example Environment variable template

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

Comment on lines +38 to +44
patient_id = parts[0]
repo = self._ensure_repo(patient_id)
lock = self._locks[patient_id]
full_path = os.path.join(repo.working_tree_dir, *parts[1:])
os.makedirs(os.path.dirname(full_path), exist_ok=True)

# Default save uses no parent check
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

In save(), repo, lock, full_path, and the os.makedirs(...) call are computed but then ignored because the method immediately delegates to save_with_parent, which repeats the same work. This duplication adds maintenance cost and makes it easier for the two paths to diverge—consider removing the unused setup in save() and just delegating after validating the path.

Suggested change
patient_id = parts[0]
repo = self._ensure_repo(patient_id)
lock = self._locks[patient_id]
full_path = os.path.join(repo.working_tree_dir, *parts[1:])
os.makedirs(os.path.dirname(full_path), exist_ok=True)
# Default save uses no parent check
# Default save uses no parent check; repository and path setup are handled by save_with_parent

Copilot uses AI. Check for mistakes.
Comment on lines +77 to +87
# Upload v1
client.post('/upload', data={
'file': (b'initial content\nline 2\n', 'notes.txt'),
'narrative': 'Version 1'
})

# Upload v2 (same filename)
client.post('/upload', data={
'file': (b'initial content\nmodified line 2\nline 3\n', 'notes.txt'),
'narrative': 'Version 2'
})
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Same issue as above: these /upload calls are missing a multipart file object + content_type='multipart/form-data', so they won't populate request.files and won't actually test versioning/diff behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +7
<form method="post">
{{ csrf_token() }}
<label>Email</label>
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

CSRF token is currently rendered as plain text ({{ csrf_token() }}) instead of being submitted as a form field. With CSRF enabled, this form will fail validation. Render it as a hidden input (or use Flask-WTF form helpers like form.hidden_tag()).

Copilot uses AI. Check for mistakes.
Comment on lines +293 to +295
delete_entry(entry_id)
flash('Deleted')
return redirect(url_for('admin') if user.get('role')=='admin' else url_for('my_entries'))
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

entry_delete deletes by entry_id with no server-side authorization beyond “logged in”. A patient can craft a POST to delete other patients’ entries. Add an ownership/admin check (e.g., load the entry and ensure user.role == 'admin' or entry.patient_id == user.email) before calling delete_entry.

Suggested change
delete_entry(entry_id)
flash('Deleted')
return redirect(url_for('admin') if user.get('role')=='admin' else url_for('my_entries'))
entry = get_entry(entry_id)
if not entry:
flash('Entry not found')
return redirect(url_for('admin') if user.get('role') == 'admin' else url_for('my_entries'))
# authorization: only admins or the owning patient may delete
if user.get('role') != 'admin' and entry.get('patient_id') != user.get('email'):
flash('Forbidden')
return redirect(url_for('index'))
delete_entry(entry_id)
flash('Deleted')
return redirect(url_for('admin') if user.get('role') == 'admin' else url_for('my_entries'))

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +41
# attempt save with wrong parent should raise
from bhv.storage.errors import Conflict
try:
adapter.save_with_parent(rel, b'three', user_id='u3', action='edit', parent='deadbeef')
assert False, "Expected conflict"
except Conflict:
pass
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Use pytest.raises(Conflict) instead of try/except + assert False; the current pattern can hide assertion failures and produces less helpful errors when the exception isn't raised.

Copilot uses AI. Check for mistakes.

try:
import cryptography
print("cryptography OK")
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Import of 'cryptography' is not used.

Suggested change
print("cryptography OK")
print("cryptography:", getattr(cryptography, "__file__", "no file"), getattr(cryptography, "__version__", "n/a"))

Copilot uses AI. Check for mistakes.
print("cryptography import error:", repr(e))

try:
import _cffi_backend
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Import of '_cffi_backend' is not used.

Copilot uses AI. Check for mistakes.
from google.oauth2 import id_token
from google.auth.transport import requests as google_requests

from .db import init_db, create_user, get_user_by_email, create_entry, list_entries_for_patient, list_all_entries, get_entry, delete_entry, update_entry
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Import of 'get_entry' is not used.
Import of 'update_entry' is not used.

Suggested change
from .db import init_db, create_user, get_user_by_email, create_entry, list_entries_for_patient, list_all_entries, get_entry, delete_entry, update_entry
from .db import init_db, create_user, get_user_by_email, create_entry, list_entries_for_patient, list_all_entries, delete_entry

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,77 @@
import tempfile
import io
import os
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Import of 'os' is not used.

Copilot uses AI. Check for mistakes.
import shutil
import pytest
from bhv.full_app import create_app
from bhv.db import init_db
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Import of 'init_db' is not used.

Copilot uses AI. Check for mistakes.
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.

1 participant