Skip to content

Conversation

@frozendevil
Copy link
Contributor

@frozendevil frozendevil commented Oct 6, 2025

Summary

Replace hardcoded port 8020 with OS-assigned dynamic port to prevent conflicts with other applications. The OAuth server now binds to port 0 by default (when no specific port is provided in redirect URL), allowing the OS to assign an available port automatically.

Changes:

  • Modified OAuth flow to bind to dynamic port and use actual assigned port
  • Updated default redirect URL to not include hardcoded port

Resolves port conflicts during OAuth authentication flow.

Type of Change

  • [ x] Feature

Testing

Unit tests pass.

Manual test:

  • Started a python server on port 8020: python3 -m http.server 8020.
  • Removed Databricks OAuth token and verified the auth flow from the command line:
$ rm ~/.config/goose/databricks/oauth/fd697cbfcc4c3b9832447a333340aa7ccddd9a1d2c8712ef8b0be1d5a92595b2.json                                                        
$ unset DATABRICKS_TOKEN                                                                                                                                           
$ export GOOSE_DISABLE_KEYRING=true                                                                                                                                
$ ./target/release/goose run --text "hi" --provider databricks --model databricks-claude-sonnet-4                                                                  
starting session | provider: databricks model: databricks-claude-sonnet-4
    session id: 20251006_112018
    working directory: /Users/izzy/Code/goose
Hello! I'm goose, your AI assistant. I'm here to help you with a wide variety of tasks including:

- **Code development** - editing files, running commands, analyzing codebases
- **Computer automation** - controlling applications, web scraping, file processing
- **Task management** - organizing and tracking multi-step projects
- **Data processing** - working with spreadsheets, documents, PDFs
- **System operations** - shell commands, file management, automation scripts

What would you like to work on today? You can describe your task and I'll help break it down and execute it step by step.

If you need help with the interface, here are some useful commands:
- `/help` or `/?` - Display help message
- `/t` - Toggle between Light/Dark/Ansi themes  
- `/exit` or `/quit` - Exit the session
- `Ctrl+C` - Interrupt current interaction
- `Ctrl+J` - Add a newline
- `Up/Down arrows` - Navigate command history
$ 

The login redirect page opened with a URL of http://localhost:61601/?code=dcod7de228f79cd0fecbe7b0955105959de8&state=yYAiqVQQl7AeDrlX, indicating it bound to port 61601. We received a full response indicating that the subsequence communication with Databricks succeeded.

@frozendevil frozendevil marked this pull request as ready for review October 6, 2025 03:27
@michaelneale michaelneale self-assigned this Oct 6, 2025
Copy link
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

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

nice one - @frozendevil if you can update to main and push to trigger a build, we can get this in. really nice catch! we probably have other places we make this mistake too

Replace hardcoded port 8020 with OS-assigned dynamic port to prevent
conflicts with other applications. The OAuth server now binds to port 0
by default (when no specific port is provided in redirect URL), allowing
the OS to assign an available port automatically.

Changes:
- Modified OAuth flow to bind to dynamic port and use actual assigned port
- Updated default redirect URL to not include hardcoded port
- Added helper methods to handle dynamic redirect URLs
- Maintains backward compatibility for explicit port specifications

Resolves port conflicts during OAuth authentication flow.

Signed-off-by: Izzy Fraimow <[email protected]>
@frozendevil frozendevil force-pushed the fix/dynamic-oauth-port branch from 4f0b3eb to 7f954cf Compare October 7, 2025 06:14
@frozendevil
Copy link
Contributor Author

cool, thanks! The fork is up-to-date now, but I don't have permission to kickoff the workflows

Copy link
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

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

this is obviously a good fix! thanks for that.

that said, if you wanted to make it even sharper, I would the added LLM comments, the code should speak for itself. also I would put the url/port processing in get_authorization_url and not rename that thing.

@michaelneale
Copy link
Collaborator

I don't hate all the comments:

// If no port is specified (or port is explicitly 0), let the OS assign one

is nice as I always forget you can do that!
(comments are for people that forhget, like me, not those that forever remember like @DOsinga !)

nice one!

@frozendevil
Copy link
Contributor Author

Yeah, my reasoning for leaving the comments was that the port-0 behavior is something that lots of folks haven't encountered (or have forgotten). I've cleaned up the other comments though.

Re: get_authorization_url—the resolved URL is passed to both get_authorization_url and exchange_code_for_token, so the current spot seemed like the lowest common parent for both of those. Maybe I'm misunderstanding something though?

@zanesq zanesq merged commit b040cfc into block:main Oct 8, 2025
10 checks passed
@alexhancock alexhancock mentioned this pull request Oct 9, 2025
michaelneale added a commit that referenced this pull request Oct 9, 2025
* main: (170 commits)
  Applied server side call to parse and save recipe (#5022)
  feat(prompt-library): add Code Documentation Migrator intermediate prompt (#4996) (#5051)
  Add Messy Column Fixer recipe (#5062)
  Cleanup temp files (#5081)
  add openmetadata recipe (#5076)
  Fix Hacktoberfest Leaderboard (#5080)
  adding brand guidelines to AGENTS.md (#4887)
  Fix: Prevent cross-contamination of cache data across analysis modes for `analyze` tool (#5075)
  fix: remove circular reference (#5018)
  Introduced a new prompt for content amplification that integrates multi-step workflows using official Goose extensions. Closes Issue #4998 (#5050)
  Add hint for focus mode when used on file paths for `analyze` tool (#5069)
  fix: use dynamic port allocation for OAuth server (#5019)
  Art vandelay: Import & Export (#5053)
  docs: misc updates for extensions directory (#5035)
  updating recipe scanner workflows for detecting recipes from forked repos (#5056)
  feat(prompt-library): add Smart Meeting Assistant advanced prompt (#4998) (#5031)
  Allow auto focus and typing while chat is initializing (#5043)
  docs(blog): Add blog for running Goose in containerized envs  (#5052)
  fix: Add WINDOWS_CODESIGN_CERTIFICATE to nightly workflow (#5037)
  Developer `analyze` tool improvement (#5030)
  ...
tlongwell-block added a commit that referenced this pull request Oct 10, 2025
* origin/main:
  Improve Rust analysis output for `analyze` tool (#5072)
  Remove duplicate prepare_reply_context call (#5063)
  install react dev tools in development (#4979)
  Doc: Added powershell installation link to the guide (#5012)
  draft of new blog post about automating more automation (#5038)
  Subagent extension selection behavior fix (#5093)
  Add dev and alpha environment indicator (#5092)
  docs: add content carousel (#5086)
  Applied server side call to parse and save recipe (#5022)
  feat(prompt-library): add Code Documentation Migrator intermediate prompt (#4996) (#5051)
  Add Messy Column Fixer recipe (#5062)
  Cleanup temp files (#5081)
  add openmetadata recipe (#5076)
  Fix Hacktoberfest Leaderboard (#5080)
  adding brand guidelines to AGENTS.md (#4887)
  Fix: Prevent cross-contamination of cache data across analysis modes for `analyze` tool (#5075)
  fix: remove circular reference (#5018)
  Introduced a new prompt for content amplification that integrates multi-step workflows using official Goose extensions. Closes Issue #4998 (#5050)
  Add hint for focus mode when used on file paths for `analyze` tool (#5069)
  fix: use dynamic port allocation for OAuth server (#5019)
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.

4 participants