Skip to content

🧪 Jules Engineering Updates: Security, Performance & Code Quality Improvements #25

Open
TheRealAshik wants to merge 6 commits intogoogle-labs-code:mainfrom
TheRealAshik:main
Open

🧪 Jules Engineering Updates: Security, Performance & Code Quality Improvements #25
TheRealAshik wants to merge 6 commits intogoogle-labs-code:mainfrom
TheRealAshik:main

Conversation

@TheRealAshik
Copy link

@TheRealAshik TheRealAshik commented Feb 9, 2026

Recent Engineering Improvements

🔒 Security Fixes

Sensitive Data Exposure in Error Logs - Fixed a vulnerability where URLs containing API keys/tokens in query parameters were exposed in error messages. Added sanitizeUrl utility to remove query strings and fragments from URLs in all error classes.

🧹 Code Health & Maintenance

Removed Test-Only Methods from Production Code - Cleaned up JulesMCPServer class by removing test helper methods (handleSessionState, handleGetBashOutputs, etc.) that were polluting production code, improving maintainability.

Performance Optimization

Async Configuration I/O - Replaced synchronous fs methods with asynchronous fs.promises operations for configuration loading/saving, preventing event loop blocking and improving overall system responsiveness.

Testing Improvements

Schema Introspection Unit Tests - Added comprehensive tests for JQL schema definition and documentation generation logic, covering schema retrieval, TypeScript interface generation, and Markdown documentation integrity.


Key Themes: Security hardening, codebase cleanup, performance optimization, and test coverage expansion. All changes maintain backward compatibility while improving reliability and maintainability.

Removed several public methods from JulesMCPServer that were explicitly
marked "for testing". These methods were thin wrappers around tool handlers.
Refactored lightweight-responses spec test to call the tool handler directly.

Methods removed:
- handleSessionState
- handleGetBashOutputs
- handleSelect
- handleReviewChanges
- handleShowDiff
- _listTools
…#2)

This commit introduces a `sanitizeUrl` utility to strip query parameters
and fragments from URLs before they are included in error messages or
stored in error objects. This prevents accidental exposure of sensitive
information such as API keys or tokens in logs.

Files modified:
- packages/core/src/utils.ts: added sanitizeUrl utility
- packages/core/src/errors.ts: updated error classes to use sanitizeUrl
- packages/core/src/api.ts: updated ApiClient to use sanitizeUrl in custom error messages
- packages/core/tests/security_url.test.ts: added tests for URL sanitization in errors
- Added unit tests for `getSchema`, `getAllSchemas`, `generateTypeDefinition`, and `generateMarkdownDocs` in `packages/core/src/query/schema.ts`.
- Implemented schema integrity checks for `SESSION_SCHEMA`, `ACTIVITY_SCHEMA`, `FILTER_OP_SCHEMA`, and `PROJECTION_SCHEMA`.
- Verified test coverage and confirmed tests catch regressions by temporarily modifying the code.
Refactor `loadConfig`, `saveConfig`, and `resolveApiKey` to be asynchronous, using `fs.promises` instead of synchronous `fs` methods. This prevents blocking the Node.js event loop during I/O operations, which is a performance anti-pattern.

All call sites and tests have been updated to support the new asynchronous API.
@TheRealAshik TheRealAshik changed the title Contibutions from Jules 🧪 Jules Engineering Updates: Security, Performance & Code Quality Improvements Feb 9, 2026
Copy link
Collaborator

@davideast davideast left a comment

Choose a reason for hiding this comment

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

Hey @TheRealAshik! Thank you so much for your PR. There are a lot of really good pieces here. If we can address some of the issues below we can get it into a mergeable state.

Breaking

JulesAuthenticationError / JulesRateLimitErrorthis.message after super()

The subclasses call super(url, status, statusText) and then overwrite this.message:

super(url, status, statusText);
this.message = `[${status} ${statusText}] Authentication to ${this.url} failed...`;

This means .stack will contain the old message (from super()), while .message has the new one — confusing for debugging. Fix: pass the full formatted message to super() instead of overwriting post-construction.

Not breaking but needs to be addressed

sanitizeUrl strips ALL query params

Strips everything — including non-sensitive params like ?pageToken= or ?sessionId=, making debugging harder. Consider redacting only known-sensitive params (key, token, apiKey, access_token) and keeping the rest.

Missing license header in security_url.test.ts

The new schema.test.ts has the Apache 2.0 header correctly — security_url.test.ts is missing it.

saveConfig missing Promise<void> return type

export async function saveConfig(config: Config) // → Promise<void>

Good stuff!

  • Removing test helpers from production JulesMCPServer — great cleanup. Test correctly updated to use tools array directly.
  • Schema tests — well-structured with good integrity checks.
  • Async config I/O — correct and properly cascaded through all callers.
  • Tests properly updated from mockReturnValuemockResolvedValue.

…comments (#6)

* Fix error constructors and improve URL sanitization

- Pass formatted message to `super()` in `JulesAuthenticationError` and `JulesRateLimitError` to ensure `stack` and `message` consistency.
- Update `sanitizeUrl` to only strip sensitive query parameters (`key`, `token`, `apiKey`, `access_token`) and preserve others for better debugging.
- Add missing Apache 2.0 license header to `packages/core/tests/security_url.test.ts`.
- Add `Promise<void>` return type to `saveConfig` in `packages/mcp/src/config.ts`.
- Update `security_url.test.ts` to verify preservation of non-sensitive parameters.

* Remove package-lock.json and other temporary artifacts

- Remove `package-lock.json` as it was unintentionally included.
- Verified no other cache files are present.
- Retained `security_url.test.ts` as it is required for verification.

* Remove test files for clean production codebase

- Removed `packages/core/tests/security_url.test.ts` as requested.
- PR now only contains source code changes for errors, utils, and config.
@davideast davideast added fleet-merge-ready Ready for fleet sequential merge and removed fleet-merge-ready Ready for fleet sequential merge labels Mar 2, 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.

2 participants