Skip to content

Fix Internal Server Error in group workspaces when no active group is set #257

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

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 29, 2025

Problem

Users encountered "Error loading workspaces: Internal Server Error" when accessing the group workspaces page without having an active group set. This occurred because the code attempted to execute a Cosmos DB query with a None value for the active_group_id parameter.

Root Cause

In route_frontend_group_workspaces.py, the code was:

  1. Getting active_group_id from user settings, which could be None
  2. Directly using this value in a Cosmos DB query without validation
  3. Causing the query to fail when active_group_id was None or invalid
# Before: This would crash if active_group_id is None
active_group_id = settings.get("activeGroupOid")  # Could be None
parameters = [{"name": "@group_id", "value": active_group_id}]  # None value causes error
legacy_docs_from_cosmos = list(cosmos_group_documents_container.query_items(...))

Solution

Added proper validation and error handling:

  • Only execute the Cosmos DB query when active_group_id is valid (not None or empty)
  • Wrapped the query in a try-catch block for additional resilience
  • Set legacy_count to 0 by default, ensuring the page loads successfully
# After: Safe handling with validation
legacy_count = 0
if active_group_id:  # Only query if we have a valid group ID
    try:
        # Execute Cosmos DB query safely
        legacy_docs_from_cosmos = list(cosmos_group_documents_container.query_items(...))
        legacy_count = legacy_docs_from_cosmos[0] if legacy_docs_from_cosmos else 0
    except Exception as e:
        print(f"Error querying legacy documents: {str(e)}")
        legacy_count = 0

Impact

  • Before: Users got an Internal Server Error when visiting group workspaces without an active group
  • After: Page loads successfully, allowing users to select a group from the interface
  • Preserved: All existing functionality when a valid active group is set

Testing

  • Verified the fix handles various edge cases (None, empty string, valid IDs)
  • Confirmed exception handling works correctly
  • Validated that existing functionality is preserved
  • Checked consistency with similar validation patterns used elsewhere in the codebase

Fixes #254.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

… None

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Error loading workspaces: Internal Server Error Fix Internal Server Error in group workspaces when no active group is set May 29, 2025
@Copilot Copilot AI requested a review from paullizer May 29, 2025 16:14
Copilot finished work on behalf of paullizer May 29, 2025 16:14
paullizer and others added 4 commits May 29, 2025 12:31
* Support for custom environment (#235) (#240)

Co-authored-by: adu103 <adu103@users.noreply.github.com>
Co-authored-by: Alex Unger (Dev Advocate) <alexunger@microsoft.com>

* Fix code snippet readability in Dark Mode (#239)

* Initial plan for issue

* Add dark mode styling for code blocks

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

* Fix dark mode file link contrast in chat messages (#241)

* Initial plan for issue

* Fix dark mode file link contrast by using white text on green background

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

* update version to 0.215.001

* Admin Setting - Use Local File for Document Intelligence Testing (#245)

* Initial plan for issue

* Update Document Intelligence test to use local file

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

* initial

---------

Co-authored-by: adu103 <adu103@users.noreply.github.com>
Co-authored-by: Alex Unger (Dev Advocate) <alexunger@microsoft.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
* Support for custom environment (#235) (#240)

Co-authored-by: adu103 <adu103@users.noreply.github.com>
Co-authored-by: Alex Unger (Dev Advocate) <alexunger@microsoft.com>

* Fix code snippet readability in Dark Mode (#239)

* Initial plan for issue

* Add dark mode styling for code blocks

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

* Fix dark mode file link contrast in chat messages (#241)

* Initial plan for issue

* Fix dark mode file link contrast by using white text on green background

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

* update version to 0.215.001

* Admin Setting - Use Local File for Document Intelligence Testing (#245)

* Initial plan for issue

* Update Document Intelligence test to use local file

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>

* initial

* page size fix

---------

Co-authored-by: adu103 <adu103@users.noreply.github.com>
Co-authored-by: Alex Unger (Dev Advocate) <alexunger@microsoft.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
@paullizer
Copy link
Contributor

clicking on create new public workspace does not work

image

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented May 29, 2025

clicking on create new public workspace does not work

image
...

Fixed! The "Create New Public Workspace" modal was incomplete - it was missing the actual form fields (name input, description textarea, submit button). I've implemented the complete modal form that the JavaScript expects. The issue should now be resolved in commit 8d78d56.

Copilot finished work on behalf of paullizer May 29, 2025 17:02
@paullizer
Copy link
Contributor

I can make groups but now when i manage the group the page is empty, its not showing any details

Uncaught SyntaxError: Identifier 'workspaceId' has already been declared (at manage_public_workspace.js:1:1)

image

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented May 29, 2025

I can make groups but now when i manage the group the page is empty, its not showing any details

Uncaught SyntaxError: Identifier 'workspaceId' has already been declared (at manage_public_workspace...

Fixed! The issue was caused by a JavaScript variable conflict - both the HTML template and JavaScript file were declaring const workspaceId, which caused the syntax error. I've updated the template to assign to window.workspaceId instead. The manage group pages should now load properly. The fix is in commit b903784.

Copilot finished work on behalf of paullizer May 29, 2025 17:29
@paullizer
Copy link
Contributor

i can see content now but the name and description are not editable and when i click on Add member nothing happens. Add member should function like add member from manage_groups.html

image

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented May 29, 2025

i can see content now but the name and description are not editable and when i click on Add member nothing happens. Add member should function like add member from manage_groups.html

![image](https...

Fixed! The manage public workspace template was incomplete - it was missing the edit form fields (name/description inputs) and the Add Member modal. I've added all the missing HTML elements including the complete Add Member modal with user search functionality, matching the design from manage_groups.html. The name and description should now be editable, and the Add Member button should open a functional modal. Fixed in commit a6c399d.

Copilot finished work on behalf of paullizer May 29, 2025 18:06
@paullizer
Copy link
Contributor

image

missing name, also we dont allow change role to owner, add missing transfer ownership (like manage_groups.html)

… role option, fix member names

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>
Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented May 30, 2025

i created a prompt but after reloading the page now the page shows loading public prompts without showing anything
![image](https://github.com/user-attachments/assets/dece224c-11d8-406d-b994-3e9d406e...

Fixed! The issue was that public prompts were incorrectly using the group_prompts container and group_id field. I've updated functions_prompts.py to properly detect public_prompt type and use the correct cosmos_public_prompts_container with public_id field instead. Public prompts should now save and load correctly. Fixed in commit 365b495.

@paullizer
Copy link
Contributor

files fail during upload in public workspace

{
    "id": "4763fdf6-8b6d-4f70-b659-a3cf537bfdfd",
    "file_name": "19790022097.pdf",
    "num_chunks": 0,
    "number_of_pages": 0,
    "current_file_chunk": 0,
    "num_file_chunks": 0,
    "upload_date": "2025-05-30T11:04:05Z",
    "last_updated": "2025-05-30T11:04:05Z",
    "version": 1,
    "status": "Error: Processing failed: process_di_document() got an unexpected keyword argument 'public_workspace_id'",
    "percentage_complete": 0,
    "document_classification": "Pending",
    "type": "document_metadata",
    "public_workspace_id": "7b1d0a2f-8bf7-445a-b01c-3d00d5368469",
    "user_id": "07e61033-ea1a-4472-a1e7-6b9ac874984a",
    "_rid": "i7AdAPrzUh0DAAAAAAAAAA==",
    "_self": "dbs/i7AdAA==/colls/i7AdAPrzUh0=/docs/i7AdAPrzUh0DAAAAAAAAAA==/",
    "_etag": "\"2200fd15-0000-0100-0000-683990a50000\"",
    "_attachments": "attachments/",
    "document_id": "4763fdf6-8b6d-4f70-b659-a3cf537bfdfd",
    "_ts": 1748603045
}

Copilot finished work on behalf of paullizer May 30, 2025 11:16
…o process_di_document and helper functions

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented May 30, 2025

files fail during upload in public workspace

...

Fixed! The issue was that the process_di_document function didn't accept the public_workspace_id parameter that was being passed during public workspace file uploads. I've updated the function signature and all related helper functions (get_document_metadata, save_chunks, extract_document_metadata) to properly support public workspaces. File uploads should now work correctly in public workspaces. Fixed in commit 66abdfb.

Copilot finished work on behalf of paullizer May 30, 2025 11:26
@paullizer
Copy link
Contributor

public prompt now shows up in the correct cosmos container but the prompts are not loading

image

but when i create a new prompt than all prompts show up

image

Co-authored-by: paullizer <34814295+paullizer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented May 30, 2025

public prompt now shows up in the correct cosmos container but the prompts are not loading

image
...

Fixed! The public prompts weren't loading initially because the prompts tab was missing event listeners to load data when switching tabs. I've added proper tab change event listeners to fetch the prompts data when switching to the prompts tab, and fixed the delete_prompt_doc function to properly handle prompt types. The fix is in commit abee475.

Copilot finished work on behalf of paullizer May 30, 2025 12:27
@paullizer
Copy link
Contributor

public workspace is missing the expand view for the documents that show the meta data, edit meta data button with modal, and extract metadata button

@paullizer
Copy link
Contributor

the set active button in my public workspaces does not work

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.

Error loading workspaces: Internal Server Error
2 participants