Skip to content

Handle missing source in sourcemap gracefully#1250

Open
elias-ba wants to merge 2 commits intomainfrom
fix/sourcemap-missing-source
Open

Handle missing source in sourcemap gracefully#1250
elias-ba wants to merge 2 commits intomainfrom
fix/sourcemap-missing-source

Conversation

@elias-ba
Copy link
Contributor

@elias-ba elias-ba commented Feb 15, 2026

Short Description

Use the returnNullOnMissing parameter of sourceContentFor to avoid throwing when the source file isn't in the sourcemap (e.g. when no adaptor is provided).

See #1249

Implementation Details

When running a job without an adaptor (openfn job.js), the compiler produces a sourcemap that doesn't contain the expected file entries. If the job then errors, sourcemap-errors.ts tries smc.sourceContentFor(fileName) which throws, triggering a confusing console.warn("Error occurred trying to resolve sourcemap for ...") before the actual error.

The fix passes true as the second argument to sourceContentFor, which makes it return null instead of throwing when the source isn't found. We then skip setting error.pos.src if there's no content.

QA Notes

  1. Run openfn job.js without -a on a job that uses adaptor functions (e.g. get(...))
  2. Verify the sourcemap warning no longer appears, only the actual ReferenceError is shown

AI Usage

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

Use the returnNullOnMissing parameter of sourceContentFor to avoid
throwing when the source file isn't in the sourcemap (e.g. when no
adaptor is provided).

See #1249
@github-project-automation github-project-automation bot moved this to New Issues in v2 Feb 15, 2026
@elias-ba
Copy link
Contributor Author

Hey @josephjclark the approach I am taking here was suggested by Claude Code and kind of made sense to me. But I want you to look at this and see if it's a fix you'd want. I am just learning here and exploring the code. Thanks man

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

1 participant