← Stripe Interview Insights

Stripe·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jul 2026Remote

Summary

Stripe technical phone screen for a software engineer role, focused entirely on a partially-implemented Mako template engine. Two-part problem: find and fix parser bugs, then do AST-level work. Pretty niche stuff, I hadn't touched Mako in years.

Questions Asked (2)

Q1

Given a partially-implemented Mako-style template engine, identify and fix bugs in the template parser and string-interpolation logic, covering things like `${...}` expression handling, comments, control directives, and escape sequences.

Technical Trade-offsRoot Cause AnalysisAPI & Integrations
Author's notes

This is where I spent most of my time and honestly fumbled around more than I'd like to admit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the expected behavior of the template engine and the specific bugs, then systematically test each feature (expressions, comments, directives, escapes) with edge cases to isolate failures. Fix bugs one at a time, ensuring changes don't break other features, and validate with a comprehensive test suite.

Pro tip: Demonstrate a test-driven approach: write unit tests for each feature before fixing, and use a debugger or print statements to trace parsing steps. This shows rigor and prevents regressions.

1. Understand Requirements and Reproduce Bugs

Review the template engine's intended syntax and semantics, then create minimal test cases that reproduce each reported bug.

2. Isolate and Diagnose Each Bug

For each failing case, trace through the parser and interpolation logic to pinpoint the root cause, such as incorrect regex, state management, or escape handling.

3. Implement Targeted Fixes

Modify the code to correct the identified issues, ensuring changes are minimal and localized to avoid unintended side effects.

4. Validate with Comprehensive Tests

Run the full test suite and add new tests for edge cases (e.g., nested expressions, escaped delimiters) to confirm all features work correctly.

5. Refactor and Document

Clean up the code for readability, add comments explaining complex logic, and document any assumptions or limitations.

Key Points to Mention

  • Proper handling of nested `${...}` expressions, including balanced braces and recursive parsing.
  • Correct identification and removal of comments (e.g., `<%doc>` or `##`) without affecting surrounding content.
  • Parsing control directives like `% if`, `% for`, and `% end` with correct indentation and block matching.
  • Escape sequences (e.g., `\${` or `\\`) to allow literal delimiters in output.
  • State management in the parser to track context (e.g., inside expression, comment, or directive).
  • Error handling for malformed templates, such as unclosed expressions or mismatched directives.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Work with the AST representation of Mako templates to support more advanced features: add a missing visitor method, fix a misnamed node attribute, or extend a `visit_*` method to handle a new node type.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

The misnamed attribute part was actually the easiest win once I slowed down and read the node class definition carefully.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the specific AST modification needed by examining the existing Mako AST code and its visitor pattern. Then, implement the change (add visitor method, fix attribute name, or extend visit_* method) while ensuring consistency with the AST structure and updating any related tests. Finally, verify the change by running the test suite and considering edge cases like new node types or attribute usage.

Pro tip: Demonstrate familiarity with Mako's AST by referencing its use of the visitor pattern and how nodes like `Code` and `Expression` are structured; this shows you've worked with similar template engines and can navigate unfamiliar codebases quickly.

1. Understand the AST and visitor pattern

Review Mako's AST node definitions and the visitor base class to identify how nodes are traversed and what methods exist. Locate the specific area where the change is needed (e.g., missing visitor method, misnamed attribute).

2. Implement the required change

For a missing visitor method, add a `visit_<NodeType>` method that handles the node appropriately. For a misnamed attribute, correct the attribute name in the node class and update all references. For extending a `visit_*` method, add logic to handle the new node type, ensuring it integrates with existing traversal.

3. Update tests and documentation

Add or modify unit tests to cover the new behavior, including edge cases. Update any relevant documentation or comments to reflect the change, ensuring maintainability.

4. Run tests and validate

Execute the test suite to confirm the change works and doesn't break existing functionality. If possible, create a small template that exercises the new feature to validate end-to-end.

5. Consider broader implications

Think about how the change affects other parts of the system, such as code generation or error handling. If the change is part of a larger feature, discuss potential trade-offs or alternative approaches.

Key Points to Mention

  • Visitor pattern and its role in AST traversal
  • Mako AST node structure and common node types (e.g., Code, Expression, Text)
  • Importance of maintaining backward compatibility when renaming attributes
  • Testing strategies for AST modifications, including unit and integration tests
  • Potential performance implications of adding new node handling
  • How to approach unfamiliar codebases and contribute effectively

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.