Skip to content

Conversation

@sdzh-atlassian
Copy link
Member

What Is This Change?

Small fix to prevent an error in bitbucket logic if the remote URL is too long (the default value is 100 characters)

Error: Input exceeds maximum length. If needed, change the value of parseUrl.MAX_INPUT_LENGTH.

Source of the error: parse-url <- git-up <- git-url-parse

How Has This Been Tested?

See loom:
https://www.loom.com/share/b59e9314d6694d37aaa491d6bb9db546

Basic checks:

  • npm run lint
  • npm run test

}
}),
);
try {
Copy link
Member Author

Choose a reason for hiding this comment

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

Only added the try/catch block

"p-queue": "^6.3.0",
"p-settle": "^3.1.0",
"p-timeout": "^3.2.0",
"parse-url": "^8.1.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

eslint gets mad if we don't have this as a direct dependency but try to import it

// Override the max input length to support long Bitbucket Server URLs
// The error is thrown in `parse-url` <- `git-up` <- `git-url-parse`, hence the odd modification here
const parseUrl = require('parse-url');
parseUrl.MAX_INPUT_LENGTH = 3000;
Copy link
Member Author

Choose a reason for hiding this comment

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

per the recommendation in the error itself; require since it's pure JS

@atlassian
Copy link
Contributor

atlassian bot commented Dec 5, 2025

The issue is ready for review, and the acceptance criteria have been met:

  • ✅ Investigate the cause of the plugin crash due to URL length exceeding MAX_INPUT_LENGTH.
  • ✅ Implement a fix to handle long URLs without crashing the plugin.
  • ✅ Consider adjusting the parseUrl.MAX_INPUT_LENGTH or handle the error gracefully.

Check Jira issue

1 similar comment
@atlassian
Copy link
Contributor

atlassian bot commented Dec 5, 2025

The issue is ready for review, and the acceptance criteria have been met:

  • ✅ Investigate the cause of the plugin crash due to URL length exceeding MAX_INPUT_LENGTH.
  • ✅ Implement a fix to handle long URLs without crashing the plugin.
  • ✅ Consider adjusting the parseUrl.MAX_INPUT_LENGTH or handle the error gracefully.

Check Jira issue


// Override the max input length to support long Bitbucket Server URLs
// The error is thrown in `parse-url` <- `git-up` <- `git-url-parse`, hence the odd modification here
const parseUrl = require('parse-url');
Copy link
Contributor

Choose a reason for hiding this comment

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

🔎 Code Readability

Use ES6 import syntax to match the rest of the file: import * as parseUrl from 'parse-url';

Details

📖 Explanation: Mixing import styles reduces code consistency and the require() syntax doesn't provide TypeScript type checking benefits.

Suggested change
const parseUrl = require('parse-url');
import * as parseUrl from 'parse-url';

Uses AI. Verify results. Give Feedback

@sdzh-atlassian sdzh-atlassian force-pushed the AXON-1640-fix-long-url-parsing branch from e934614 to 93f7093 Compare December 5, 2025 02:53
this._onDidChangeBitbucketContext.fire();
this._onDidChangeBitbucketContext.fire();
} catch (err) {
err.subject_url = undefined; // remove potentially sensitive info
Copy link
Contributor

Choose a reason for hiding this comment

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

🔎 Code Design - Null Check

Accessing err.subject_url without checking if it exists could throw a runtime error if err is not an object or lacks this property.

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