Skip to content
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

fix: improve teams settings in workspace settings #5316

Merged
merged 3 commits into from
Feb 17, 2025
Merged

Conversation

alpetric
Copy link
Contributor

@alpetric alpetric commented Feb 17, 2025

Important

Update SQL queries for better JSON handling and update ee-repo-ref.txt to a new reference.

  • SQL Queries:
    • Replaces query-2fa27b0a71740e4e168879cf9a58ed593004c22bb5d11170b3196e290dd1d966.json with query-50c17c7848760aaf0f869acfc444caecda6335eda5b2e97e5a7370361653ff48.json to handle JSON arrays more robustly in global_settings.
    • Adds query-65c339164e7669360d231d70105849e72bdc197c17c0fc51777c1dc9267e2daf.json to reset teams_command_script, teams_team_id, and teams_team_name in workspace_settings.
    • Updates query-ddf2eccb78a310ed00c7d8b9c3f05d394a7cbcf0038c72a78add5c7b02ef5927.json to change nullable from true to null.
    • Adds query-df3b60c1d0fb44c97bf2611a7cda6bdb16a1be66e993a5cfadf6de2e3c8a5021.json to update global_settings by removing teams_channel elements.
    • Adds query-e565f3b2e51059f563d18a8a9442bcae9640cee7b936820cb46c011222a77ff0.json to update teams in global_settings with a JSONB parameter.
  • Misc:
    • Updates ee-repo-ref.txt to new hash e507af5589efb1a8a72ae4e231130f749bde738d.

This description was created by Ellipsis for a02d838. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to af19721 in 36 seconds

More details
  • Looked at 9 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. backend/ee-repo-ref.txt:1
  • Draft comment:
    Commit hash updated to new reference; change appears straightforward.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. backend/ee-repo-ref.txt:1
  • Draft comment:
    Verify updated commit hash is correct.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
3. backend/ee-repo-ref.txt:1
  • Draft comment:
    Consider adding a trailing newline for style consistency if required by the project's guidelines.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None

Workflow ID: wflow_s6LbaiC6OO3Fi6Mx


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

cloudflare-workers-and-pages bot commented Feb 17, 2025

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0979b49
Status: ✅  Deploy successful!
Preview URL: https://7fb6ece9.windmill.pages.dev
Branch Preview URL: https://alp-latest-ee.windmill.pages.dev

View logs

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on a02d838 in 2 minutes and 6 seconds

More details
  • Looked at 131 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 7 drafted comments based on config settings.
1. backend/.sqlx/query-65c339164e7669360d231d70105849e72bdc197c17c0fc51777c1dc9267e2daf.json:3
  • Draft comment:
    Update statement appears appropriate; review access rights and transactional consistency.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. backend/.sqlx/query-ddf2eccb78a310ed00c7d8b9c3f05d394a7cbcf0038c72a78add5c7b02ef5927.json:17
  • Draft comment:
    Nullable flag changed from 'true' to 'null'. Confirm if this change correctly reflects the column’s nullability.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50%
    This appears to be an auto-generated file based on the .sqlx extension and its JSON structure. The change is likely a result of the SQL query tooling rather than a direct manual edit. The nullability change itself doesn't indicate a problem - both null and true would allow null values, and this is metadata rather than actual code logic.
    The comment might be pointing out a potential schema inconsistency that could cause runtime issues. Generated files can sometimes indicate underlying problems.
    However, this is clearly a generated file, and any actual schema issues would be caught by the build process or database migrations. Commenting on generated files violates our review principles.
    Delete the comment as it's discussing a change in a generated file, which should not be manually reviewed or modified.
3. backend/.sqlx/query-df3b60c1d0fb44c97bf2611a7cda6bdb16a1be66e993a5cfadf6de2e3c8a5021.json:3
  • Draft comment:
    UPDATE statement for global_settings looks correct; verify that filtering out 'teams_channel' is intended.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. backend/.sqlx/query-e565f3b2e51059f563d18a8a9442bcae9640cee7b936820cb46c011222a77ff0.json:3
  • Draft comment:
    UPDATE global_settings setting the value for 'teams' seems fine; ensure proper Jsonb handling in application code.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
5. backend/.sqlx/query-50c17c7848760aaf0f869acfc444caecda6335eda5b2e97e5a7370361653ff48.json:20
  • Draft comment:
    Potential JSON key mismatch: the SELECT extracts team->>'team_internal_id' as team_id, yet the WHERE clause checks team->>'team_id' IS NOT NULL. Confirm if this is intentional.
  • Reason this comment was not posted:
    Marked as duplicate.
6. backend/.sqlx/query-65c339164e7669360d231d70105849e72bdc197c17c0fc51777c1dc9267e2daf.json:3
  • Draft comment:
    Confirm that nulling all team-related columns in workspace_settings is intentional as it resets team associations.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    The comment violates one of our key rules: "Do NOT ask the PR author to confirm their intention". The comment is asking for confirmation that nulling these fields is intentional. We should assume the author knows what they're doing when making database changes. Additionally, this is a .sqlx file which is typically generated from actual code, so the intention would be better reviewed in the source code that generates this query.
    Perhaps nulling all team-related fields could have serious implications for the application's functionality that we should warn about?
    While the change might be impactful, asking for confirmation isn't helpful - we should trust that the author has considered the implications of their changes. If there was a specific technical issue, that would be worth commenting on.
    The comment should be deleted as it merely asks for confirmation of intention, which violates our review rules.
7. backend/.sqlx/query-ddf2eccb78a310ed00c7d8b9c3f05d394a7cbcf0038c72a78add5c7b02ef5927.json:17
  • Draft comment:
    Nullable metadata changed from 'true' to 'null'. Verify that this update aligns with intended schema definitions and does not break dependent code.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_N1E2fUDaWvs7zJeK


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -0,0 +1,26 @@
{
"db_name": "PostgreSQL",
"query": "\n WITH assigned_teams AS (\n SELECT teams_team_id\n FROM workspace_settings\n ),\n all_teams AS (\n SELECT jsonb_array_elements(CASE\n WHEN jsonb_typeof(value::jsonb) = 'array' THEN value::jsonb\n ELSE '[]'::jsonb\n END) AS team\n FROM global_settings\n WHERE name = 'teams'\n )\n SELECT team->>'team_name' AS team_name, team->>'team_internal_id' AS team_id\n FROM all_teams\n WHERE NOT EXISTS (\n SELECT 1\n FROM assigned_teams\n WHERE assigned_teams.teams_team_id = team->>'team_internal_id'\n )\n AND team->>'team_name' IS NOT NULL\n AND team->>'team_id' IS NOT NULL\n ",
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible key name mismatch: the SELECT uses team->>'team_internal_id' AS team_id, but the null check uses team->>'team_id'. Ensure consistent key usage.

Suggested change
"query": "\n WITH assigned_teams AS (\n SELECT teams_team_id\n FROM workspace_settings\n ),\n all_teams AS (\n SELECT jsonb_array_elements(CASE\n WHEN jsonb_typeof(value::jsonb) = 'array' THEN value::jsonb\n ELSE '[]'::jsonb\n END) AS team\n FROM global_settings\n WHERE name = 'teams'\n )\n SELECT team->>'team_name' AS team_name, team->>'team_internal_id' AS team_id\n FROM all_teams\n WHERE NOT EXISTS (\n SELECT 1\n FROM assigned_teams\n WHERE assigned_teams.teams_team_id = team->>'team_internal_id'\n )\n AND team->>'team_name' IS NOT NULL\n AND team->>'team_id' IS NOT NULL\n ",
"query": "\n WITH assigned_teams AS (\n SELECT teams_team_id\n FROM workspace_settings\n ),\n all_teams AS (\n SELECT jsonb_array_elements(CASE\n WHEN jsonb_typeof(value::jsonb) = 'array' THEN value::jsonb\n ELSE '[]'::jsonb\n END) AS team\n FROM global_settings\n WHERE name = 'teams'\n )\n SELECT team->>'team_name' AS team_name, team->>'team_internal_id' AS team_id\n FROM all_teams\n WHERE NOT EXISTS (\n SELECT 1\n FROM assigned_teams\n WHERE assigned_teams.teams_team_id = team->>'team_internal_id'\n )\n AND team->>'team_name' IS NOT NULL\n AND team->>'team_internal_id' IS NOT NULL\n "

@@ -0,0 +1,12 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE global_settings\n SET value = (\n SELECT jsonb_agg(elem)\n FROM jsonb_array_elements(value) AS elem\n WHERE NOT (elem ? 'teams_channel')\n )\n WHERE name = 'critical_error_channels'\n ",
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using COALESCE with jsonb_agg (e.g. COALESCE(jsonb_agg(elem), '[]'::jsonb)) to ensure an empty array is returned instead of NULL when no elements pass the filter.

Suggested change
"query": "\n UPDATE global_settings\n SET value = (\n SELECT jsonb_agg(elem)\n FROM jsonb_array_elements(value) AS elem\n WHERE NOT (elem ? 'teams_channel')\n )\n WHERE name = 'critical_error_channels'\n ",
"query": "\n UPDATE global_settings\n SET value = (\n SELECT COALESCE(jsonb_agg(elem), '[]'::jsonb)\n FROM jsonb_array_elements(value) AS elem\n WHERE NOT (elem ? 'teams_channel')\n )\n WHERE name = 'critical_error_channels'\n ",

@rubenfiszel rubenfiszel changed the title update latest ee reference fix: improve teams settings in workspace settings Feb 17, 2025
@rubenfiszel rubenfiszel merged commit 935b5b7 into main Feb 17, 2025
3 checks passed
@rubenfiszel rubenfiszel deleted the alp/latest_ee branch February 17, 2025 21:44
@github-actions github-actions bot locked and limited conversation to collaborators Feb 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants