Skip to content

Hooks for bazaar#254

Draft
jumpyvi wants to merge 2 commits intoprojectbluefin:mainfrom
jumpyvi:bazaar-hooks
Draft

Hooks for bazaar#254
jumpyvi wants to merge 2 commits intoprojectbluefin:mainfrom
jumpyvi:bazaar-hooks

Conversation

@jumpyvi
Copy link
Copy Markdown

@jumpyvi jumpyvi commented Mar 30, 2026

It would be nice to add Visual Studio Cod{e/ium} / Google Studio support too before merge

About issue #240

Copy link
Copy Markdown
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 pull request implements a mechanism to discourage the installation of JetBrains IDEs via Flatpak, instead guiding users toward the JetBrains Toolbox. It adds a new hook configuration in bazaar.yaml, modifies the blocklist.yaml to allow the hook to intercept these installations, and introduces a Python script hooks.py to handle the logic. Review feedback identified a critical bug in how terminal commands are spawned, a potential AttributeError when environment variables are missing, and a recommendation to avoid bare exception handlers.

subprocess.Popen(args, start_new_session=True, stdout=subprocess.DEVNULL)

def spawn_ujust(id):
spawn_and_detach(['flatpak-spawn', '--host', 'xdg-terminal-exec', '-x', f'ujust {id}'])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The command and its arguments are being passed as a single string f'ujust {id}' to xdg-terminal-exec. This is likely to fail because the shell will try to execute a program named "ujust install-jetbrains-toolbox" instead of the ujust command with install-jetbrains-toolbox as an argument. The command and its arguments should be passed as separate elements in the list.

Suggested change
spawn_and_detach(['flatpak-spawn', '--host', 'xdg-terminal-exec', '-x', f'ujust {id}'])
spawn_and_detach(['flatpak-spawn', '--host', 'xdg-terminal-exec', '-x', 'ujust', id])

def handle_jetbrains():

def appid_is_jetbrains(appid):
return appid.startswith('com.jetbrains.')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The appid variable, which comes from os.getenv('BAZAAR_TS_APPID'), can be None if the environment variable is not set. Calling .startswith() on None will raise an AttributeError, causing the script to crash. You should add a check to ensure appid is not None before calling string methods on it.

Suggested change
return appid.startswith('com.jetbrains.')
return appid is not None and appid.startswith('com.jetbrains.')

case 'action':
try:
spawn_ujust('install-jetbrains-toolbox')
except:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Using a bare except: is generally discouraged as it catches all exceptions, including system-exiting ones like SystemExit or KeyboardInterrupt. This can hide bugs and make the program difficult to interrupt or debug. It's better to catch a more specific exception, like Exception.

Suggested change
except:
except Exception:

@jumpyvi jumpyvi changed the title Bare minimum hooks for bazaar Hooks for bazaar Mar 30, 2026
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