← Stripe Interview Insights

Stripe·Software Engineer·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

Stripe debugging interview for a software engineering role. The whole thing was focused on a real open-source codebase (Mako templates) and you had to find two specific bugs, not just write code from scratch. Felt more like a code review session than a typical coding round.

Questions Asked (2)

Q1

In the Mako template library source, there's a bug in a file path check using os.path.isdir. What's wrong with it and how do you fix it?

Root Cause AnalysisTechnical Trade-offs
Author's notes

The variable being passed to os.path.isdir was scrfile, which at that point in the code is the source file path, not a directory.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, explain the bug: os.path.isdir follows symlinks and returns True for directories, but the check likely intended to verify a regular file or handle non-existent paths. Then, describe the fix: use os.path.isfile or os.path.exists with appropriate logic, and consider symlink behavior. Finally, discuss trade-offs like security and cross-platform compatibility.

Pro tip: Mention that os.path.isdir can raise an exception if the path is too long or contains null bytes, so wrapping in try-except or using os.path.exists is safer. Also, note that in Mako, the check might be for a directory to search for templates, so the bug could be a logic error (e.g., checking isdir instead of isfile).

1. Identify the bug

Explain that os.path.isdir returns True for directories, including symlinks to directories, but the code likely intended to check for a regular file or handle non-existent paths. This can cause incorrect behavior, such as treating a directory as a valid file.

2. Analyze the impact

Discuss how this bug could lead to security issues (e.g., path traversal) or functional errors (e.g., trying to read a directory as a file). Consider the context of Mako's template loading.

3. Propose a fix

Suggest using os.path.isfile to check for regular files, or os.path.exists combined with os.path.isdir as needed. If symlinks are a concern, use os.path.islink or os.path.realpath.

4. Consider edge cases

Mention handling of non-existent paths, permission errors, and cross-platform differences (e.g., Windows vs. Unix). Also, note that os.path.isdir can raise exceptions for invalid paths.

5. Test and validate

Describe how to write unit tests to verify the fix, including cases with directories, files, symlinks, and non-existent paths.

Key Points to Mention

  • os.path.isdir follows symlinks and returns True for directories, which may not be the intended check.
  • The bug could be a logic error: checking for a directory when the code expects a file.
  • Use os.path.isfile for regular files, or os.path.exists for existence checks.
  • Consider security implications: symlink attacks or path traversal.
  • Handle exceptions: os.path.isdir can raise OSError for invalid paths.
  • Cross-platform compatibility: Windows vs. Unix path handling.

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

Q2

There's also a bug in an AST visitor method signature in the same codebase. The method is defined as visit_arg(self, node) but it doesn't work correctly. What's the issue?

Root Cause AnalysisAPI & Integrations
Author's notes

This one got me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, explain that AST visitor methods in Python's ast module are expected to return a value (typically the node or a replacement) and that the method name must match the node type exactly (e.g., visit_arg for ast.arg). Then, point out that the signature visit_arg(self, node) is correct in terms of parameters, but the issue likely lies in the return statement or in how the visitor is invoked (e.g., missing generic_visit call or incorrect return).

Pro tip: Mention that in Python's ast.NodeVisitor, the visit method dispatches to visit_<nodetype> and if that method returns None, the traversal stops for that node's children unless generic_visit is called. This shows deep understanding of the framework.

1. Identify the expected behavior

Explain that AST visitor methods should process the node and typically return a value (often the node itself or a modified node) to continue traversal.

2. Check method naming and signature

Confirm that the method name matches the node type (visit_arg for ast.arg) and that the signature includes self and node, which it does.

3. Analyze the method body

Look for missing return statements or missing calls to self.generic_visit(node), which would cause child nodes not to be visited.

4. Consider the visitor's usage

Check if the visitor is used with ast.NodeVisitor or ast.NodeTransformer; the latter expects return values to replace nodes.

5. Propose a fix

Suggest adding a return statement (e.g., return node) or calling generic_visit, depending on the intended behavior.

Key Points to Mention

  • AST visitor pattern in Python's ast module
  • Method naming convention: visit_<NodeType> (case-sensitive)
  • Return value expectations for NodeVisitor vs NodeTransformer
  • The role of generic_visit in traversing child nodes
  • Common pitfalls: missing return, incorrect method name, not calling generic_visit
  • Debugging approach: add print statements or use a debugger to trace visitor calls

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