Skip to content

Conversation

@jftl6y
Copy link

@jftl6y jftl6y commented Nov 5, 2025

Added fixes to allow public/group document bulk upload via API. Added a PowerShell version of the BulkLoader utility with README.md with more detail on configuring the service principals.

@Bionic711
Copy link
Collaborator

@jftl6y Will you please parameterize the SimpleChat FQDN in the Powershell Script? Make it a mandatory parameter. @paullizer and I will finish reviewing this PR today I believe.

Copy link
Contributor

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

This PR adds bulk document upload functionality to SimpleChat via external API endpoints, introducing support for both public and group workspace document uploads through a new PowerShell-based utility called PSLoader.

Key Changes

  • Added new external API routes for group document management (upload, list, delete) using OAuth Bearer token authentication
  • Created PSLoader PowerShell utility with comprehensive documentation for bulk document uploads
  • Fixed spelling in app.py comment ("Extenral" → "External")

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 32 comments.

File Description
application/single_app/route_external_group_documents.py New file implementing external API routes for group workspace document operations (upload, list, delete) with OAuth authentication
application/single_app/app.py Added imports and route registration for group documents API, fixed typo in comment
application/external_apps/PSLoader/README.md Comprehensive documentation for PSLoader utility including setup, authentication, usage examples, and troubleshooting
application/external_apps/PSLoader/PSLoader.ps1 PowerShell script implementing bulk document upload with OAuth client credentials flow and multi-cloud support

- `.pdf`, `.docx`, `.txt`, `.md`, `.html`

### Spreadsheets
- `.xsl`, `.xslx`, `.csv`
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Spelling error: .xsl should be .xls (Excel spreadsheet file extension). The correct extension is .xls, not .xsl (which is for XSL Transformation files).

Suggested change
- `.xsl`, `.xslx`, `.csv`
- `.xls`, `.xlsx`, `.csv`

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jftl6y This one as well.

write-host "Retrieved access token. Beginning file upload process..."

$files = @(Get-ChildItem -Path $uploadDirectory -File -Recurse -Include *.pdf, *.docx, *.pptx, *.txt, *.md, *.json, *.html, `
*.xsl, *.xslx, *.csv, *.jpg, *.jpeg, *.png, *.bmp, *.tiff, *.tif, *.heif, `
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Spelling error: .xsl should be .xls (Excel spreadsheet file extension). The correct extension is .xls, not .xsl (which is for XSL Transformation files).

Suggested change
*.xsl, *.xslx, *.csv, *.jpg, *.jpeg, *.png, *.bmp, *.tiff, *.tif, *.heif, `
*.xls, *.xlsx, *.csv, *.jpg, *.jpeg, *.png, *.bmp, *.tiff, *.tif, *.heif, `

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jftl6y This one as well.


```powershell
# Current (line 119):
$uploadResponse = Invoke-RestMethod -Method Post -Uri "https://your-simplechat-api-endpoint/api/external/public/documents/upload" -Headers $headers -Form $form
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Inconsistent API endpoint path: Line 262 shows the endpoint as https://your-simplechat-api-endpoint/api/external/public/documents/upload with /api/ prefix, but line 265 shows it as https://your-app.azurewebsites.net/external/public_documents/upload without /api/ prefix. The correct path (based on the route definition in the code) should not include /api/ prefix. Please correct line 262 to match the actual route pattern.

Suggested change
$uploadResponse = Invoke-RestMethod -Method Post -Uri "https://your-simplechat-api-endpoint/api/external/public/documents/upload" -Headers $headers -Form $form
$uploadResponse = Invoke-RestMethod -Method Post -Uri "https://your-simplechat-api-endpoint/external/public_documents/upload" -Headers $headers -Form $form

Copilot uses AI. Check for mistakes.

$uploadResponse = Invoke-RestMethod `
-Method Post `
-Uri "https://your-simplechat-api-endpoint/api/external/public/documents/upload" `
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Incorrect API endpoint path: The endpoint path includes /api/ prefix (/api/external/public/documents/upload), but based on the route definitions in the code, the correct path should be /external/public_documents/upload (without /api/ and with underscore in public_documents). Please correct this to match the actual route pattern.

Suggested change
-Uri "https://your-simplechat-api-endpoint/api/external/public/documents/upload" `
-Uri "https://your-simplechat-api-endpoint/external/public_documents/upload" `

Copilot uses AI. Check for mistakes.
"""
user_id = request.args.get('user_id')
active_workspace_id = request.args.get('active_workspace_id') # This is group_id

Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Missing input validation: The user_id and active_workspace_id parameters are not validated for presence before being used in database queries. If these are None, it could lead to unexpected query behavior. Consider adding validation checks similar to the upload endpoint (lines 32-36).

Suggested change
if not user_id or not active_workspace_id:
return jsonify({'error': 'user_id and active_workspace_id required'}), 400

Copilot uses AI. Check for mistakes.
# route_external_group_documents.py

from config import *
from functions_authentication import *
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Import pollutes the enclosing namespace, as the imported module functions_authentication does not define 'all'.

Suggested change
from functions_authentication import *
from functions_authentication import accesstoken_required

Copilot uses AI. Check for mistakes.
except Exception as e:
upload_errors.append(f"Failed to save temporary file for {original_filename}: {e}")
if temp_file_path and os.path.exists(temp_file_path):
os.remove(temp_file_path)
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

This statement is unreachable.

Copilot uses AI. Check for mistakes.
@Bionic711
Copy link
Collaborator

@jftl6y Review the copilot recommendations. I resolved out ones that are ignorable for us. The others, especially the ones around authorization, need to be reviewed and possibly implemented. Let us know if you have any questions (one of them covers the hard-coded endpoint in the PS script as well I mentioned earlier.).

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