Request validation vs repository validation in HAPI FHIR

Request validation checks incoming HTTP payloads, repository validation checks what gets stored. This page explains what each misses in HAPI FHIR and how to combine them within an acceptable latency budget.

On this page

Request vs repository validation in HAPI FHIR: which one your server needs

A self-hosted HAPI FHIR JPA server needs request validation, repository validation, or both, depending on which writes must be checked and which must never be stored in a non-conforming state. Request validation checks each incoming payload before the server accepts it, so the sender gets an immediate rejection. Repository validation checks a resource at the point it is stored, so it covers every path that reaches storage. If the goal is that stored data conforms to a profile such as US Core, repository validation is the control that matches that goal, while request validation gives senders feedback they can act on before a write is refused. Teams that must enforce a profile on stored data usually want both, for different reasons.

Each control has a blind spot. Request validation only sees writes that pass through the validating interceptor, so confirm which endpoints, transaction and batch bundles, and internal code paths it covers in the version you run. Repository validation sees what reaches storage, so confirm how its rejections surface to your API clients and whether your integrations can parse them. Neither control re-checks resources already stored before you enabled it. That existing data needs a separate review: run a validation pass against a copy of the database, count the failures by resource type and profile, and decide how to remediate them before enforcement starts in production.

Decide with a measurement rather than an estimate. Enable each control on a staging copy of the server, replay representative payloads at your expected write concurrency, and record latency for request validation alone, repository validation alone, and both. Validation cost grows with resource size and profile complexity, so test the resource types and profiles your senders actually use, not only small examples. Record the HAPI FHIR version and JDK in each test, because requirements change between releases. HAPI FHIR v8.8.2 was released on 25 September 2026, and version 8.2.0 requires JDK 17, so confirm the requirements for your target release in the HAPI FHIR versions documentation before you set the budget for latency.

How each approach differs in practice

Request-time validation checks each incoming HTTP payload before the server accepts it for processing. In a HAPI FHIR server, this check runs in the request path, so it inspects the body the client sent, including create, update and transaction requests. Rejected requests return an error and nothing is written, which keeps invalid input out of the database from that point forward. The check has no view of anything that was stored earlier or that arrived through another route.

  • Data seen: the inbound payload only, evaluated before the server processes the write.
  • What it misses: rows written before the rule was installed, and data loaded by batch jobs, direct database writes or import tools that bypass the REST endpoint. Confirm which loaders your teams use.
  • Latency: the validation cost is paid on every write and adds to that request's response time. Large transaction bundles multiply the effect.
  • Operations: changing an installed implementation guide changes what is accepted from that point on, but it does not re-check existing data.
  • Client feedback: senders receive OperationOutcome errors at write time, which makes defects quicker to fix.

Before relying on this layer, list every write path into the server and confirm with your platform team which ones pass through the interceptor.

What each approach misses and how to close the gap

Neither validation point sees every resource the server holds. The gaps below share one root cause: data reaches the repository through paths that skip the check, or the rules change after data was accepted. Each card names the mitigation and what to confirm in your own environment.

Legacy data never validated

Resources written before request or repository validation was switched on were never checked against the current profile. Request validation does nothing for them, and a repository check only runs when something is written again. Run a scheduled audit that searches stored resources by type and reports those that fail the profile. Then decide whether to revalidate in place, reindex, or re-ingest from source. Confirm how many resource types your database holds and when validation was first enabled in each environment.

JPA server docs

Profile version drift

When an implementation guide moves to a new version, resources validated against the old profile stay in the database and may no longer conform. Validation of new writes then uses a different rule set than the data already stored. Pin the IG version in each environment and record which version each resource was checked against. Confirm that dev, test and production load the same package version before you tighten enforcement.

Bulk loads and batch jobs

Bulk imports and batch or transaction bundles can write large volumes quickly, and their validation settings may differ from the interactive API. Some loaders write through paths that bypass the request interceptor. Route bulk loads through the same validation configuration, or run a post-load audit on the loaded resource types. Confirm which ingestion paths your teams use and whether each one passes through the same interceptors.

Server-side operations that change data

Operations such as $merge, patient matching, reindexing and other server-side jobs can alter stored resources without a client sending a payload. These changes may produce resources that no longer conform, and an HTTP-level check never sees them. Add a validation step after operations that rewrite data, and include those operations in the audit schedule. Confirm which operations your applications and administrators run against the server and who is allowed to start them.

Failures logged but not enforced

Many teams configure validation to report errors without rejecting the write, so failures accumulate in logs that nobody reads. The data is stored anyway, and the team assumes conformance. Set a clear policy for each resource type: reject on error, or accept with a tracked exception and an owner. Review the validation log output on a fixed schedule and confirm which failures block a write in your current configuration.

How a write moves through request and repository validation

The diagram starts with an HTTP client sending a POST or PUT to the HAPI FHIR JPA server. Request validation checks the payload first and adds latency before any stored state changes. Authorization interceptors run next, and repository validation checks the resource again at the point of storage, which adds a second cost. A failure at either step returns an OperationOutcome. Check the path marked as a direct SQL write, because data loaded that way reaches the relational database without passing either validation step.

Writes pass two validation points, but direct database writes skip both.

How to set up validation on a HAPI FHIR server

This sequence takes a HAPI FHIR JPA server from version confirmation to a tested state where incoming payloads and stored resources are both checked against the profiles you require. Each step ends with a check, so you know the layer works before you move to the next one.

  1. Confirm the HAPI FHIR version and JDK

    Start by fixing the HAPI FHIR version and the Java runtime your server will use. The HAPI FHIR versions documentation states that release 8.2.0 requires JDK 17, so confirm the JDK on every build and runtime host before you change anything else. Record the exact release you run, because validation class names, interceptor packages and configuration keys can change between releases. Check: the server starts on the target JDK, and the version string reported by the running server matches the release in your change record.

  2. Install the validation support and IG packages

    Configure the validation support chain that the Instance Validator uses, then load the implementation guide packages your profiles depend on, such as US Core and its dependencies. Many validation failures come from a missing package rather than a bad resource, so install the full dependency set first. Your platform team usually owns this step, and the security or interoperability lead should sign off on the list of packages. Check: a test resource that references a profile from the package validates without a 'profile not found' error, and the package versions match across environments.

  3. Register the request validation interceptor

    Add the request validation interceptor so that incoming create and update payloads are validated before the server persists them. Configure it to check the core specification and the profiles you list, and set its failure behavior so that invalid payloads return an error instead of being logged only. Confirm the exact class names and configuration keys in the release you run, since the HAPI FHIR documentation for validation is the authority for these settings. Check: a POST of a deliberately invalid resource is rejected at the HTTP layer, and the rejection appears in the server log with the validation message.

  4. Register RepositoryValidatingInterceptor with required profiles

    Register RepositoryValidatingInterceptor with the profiles you require stored data to meet, for example the US Core profiles for the resource types in scope. This interceptor validates resources as they reach the repository, so it also covers writes that do not pass through the same HTTP path your request checks assume, such as some internal and batch operations. Decide whether it rejects or tags non-conforming writes, and document that choice for the data team. Check: a write that bypasses your request-level test path still fails validation, and the server records which profile the resource failed.

  5. Test with valid and invalid sample resources

    Build a small test set with resources that should pass and resources that should fail, each labeled with the reason it should fail, such as a missing required element, a wrong code system or a cardinality violation. Send the valid set first to confirm the profiles do not reject good data, then send the invalid set through both the HTTP endpoint and the repository path. Keep the test set in version control so it can be rerun after upgrades or IG updates. Check: every valid sample is accepted and every invalid sample is rejected with the expected validation message.

  6. Check OperationOutcome responses and severities

    Read the OperationOutcome returned for each invalid sample and confirm that the issues, severities and locations match what you expected. Look at whether errors and warnings are treated as different outcomes by your configuration, since a warning that blocks writes or one that passes silently changes how data senders experience the server. Share sample OperationOutcome bodies with the teams that send data so they can fix their payloads. Check: each rejection returns an OperationOutcome that names the failing element and profile, and no invalid sample is stored as a side effect of the test.

Questions teams ask before choosing a validation setup

Can our team set up request and repository validation without outside help?

Often yes, if your team already runs a HAPI FHIR JPA server and has someone who knows FHIR profiles well. The work is configuration and testing rather than new code, but it depends on understanding which resources must conform, how strictly, and what happens to rejected writes. Teams new to FHIR validation usually find the profile and terminology decisions take longer than the configuration itself. A partner is most useful when those decisions are unclear, when several environments must stay in step, or when legacy data needs a cleanup plan. Confirm your in-house skills against the scope before deciding.

What drives the effort of validation work on a HAPI FHIR server?

Four factors drive most of the effort. The first is the number of profiles and implementation guides that must be enforced, since each adds dependencies and test cases. The second is the volume of existing data that may not conform, because cleanup and reporting scale with it. The third is your latency budget for writes, which determines how much validation can run synchronously on each request. The fourth is the number of environments, because package versions and enforcement settings must match across development, test and production. Ask for a scope that names each of these explicitly.

What does our team need to provide for the work?

You need someone who can read FHIR StructureDefinitions and explain the clinical and business meaning of each required element, plus someone who owns the enforcement decision. Representative test data is essential: valid payloads, known invalid payloads and a sample of real legacy records, handled under your data handling rules. You also need access to the target environments and a clear answer on whether invalid writes should be rejected, logged or tagged. Without that decision, configuration cannot be finished or tested, so settle it early with the people who will answer for data quality.

How long does validation setup take for different scopes?

Duration follows scope, and no fixed figure applies across projects. A single core resource type with one profile in one environment is a much smaller job than several implementation guides, multiple environments and a legacy data review. Timing also depends on how quickly your team confirms profile versions, terminology bindings and the enforcement policy. Ask for a written plan that separates configuration, test case design, legacy data analysis and rollout to each environment, with the dependencies between them stated. That structure lets you compare quotes on the same basis.

How do we measure acceptable latency for validating writes?

Measure it with your own traffic, not with a generic benchmark. Record current write latency at the percentiles your clients depend on, then add validation with the exact profiles and terminology checks you plan to enable, running in a staging environment sized like production. Repeat the test with realistic payload sizes and concurrent clients, since validation cost grows with resource complexity and terminology lookups. The result tells you whether to validate every write synchronously, validate only at the request boundary, or run repository checks as a scheduled job. Document the budget before tuning so the decision is repeatable.

What happens to data already stored before we turn on validation?

Turning on validation at the request layer does not change resources already in the database, so existing records can remain non-conformant until someone addresses them. Repository validation, by contrast, is the mechanism that checks stored data, which is why teams often use it to find problem records. Plan for a legacy review: run a validation report over the existing data, group failures by cause, decide which records to correct, which to leave with documented exceptions, and how corrections are applied and audited. Expect this review to be one of the larger parts of the project when the existing data volume is high.

Should we validate every write or only validate at the API boundary?

Validating every write gives the strongest guarantee that stored data conforms, but it adds latency and makes the server stricter for every client. Validating only at the HTTP boundary is cheaper per request and catches most bad payloads from clients, but it misses data that enters through other paths, such as bulk loads, batch jobs or changes made after a profile update. Many teams combine both: request validation for interactive clients with a tight latency budget, and periodic repository validation to find what slipped through. Your choice should follow the latency measurements and the data sources you actually have.

Security and operational considerations for validation

Validation changes what callers can learn, what gets logged and how the server behaves after each change. The cards below cover the security and operating decisions that come with choosing request, repository or combined validation on a HAPI FHIR JPA server.

Validation errors can expose profile details

An OperationOutcome returned on a rejected write often names the profile, the slice, the element path and the expected terminology. A caller probing your server can use that detail to learn which rules protect which data. Decide how verbose validation messages should be for external callers, and compare what an internal client and an outside partner receive from the same endpoint. Test rejected payloads with a low-privilege account and review what comes back.

HAPI security docs

Validation is not authorization

A payload that passes US Core or base FHIR validation is well formed, but it is not necessarily allowed. A valid Patient write from a user who should only read still has to be refused. HAPI FHIR does not provide one security layer for you, so access rules come from building blocks such as the AuthorizationInterceptor. Confirm that every write path, including batch and transaction bundles, passes through the same authorization checks as the validation interceptors.

Log rejected writes for audit

Rejected requests show who tried to send which kind of data and when, which matters for both incident response and access reviews. Keep the caller identity, the resource type, the profile checked and the outcome with each rejection. Decide where these logs go, how long they are kept and who can read them, since the payloads themselves may contain patient data. Confirm that your audit setup, including BALP audit logging, captures rejections and not only successful reads and writes.

Control where IG packages come from

Validation is only as trustworthy as the profiles it loads. An IG package pulled from an unexpected URL can change what counts as valid, so the server should accept packages only from sources you have approved. Restrict the package download URLs, record which package version each environment runs and review changes before they reach production. The package URL restriction topic covers allow lists, private network rules and redirect handling in detail.

Monitor validation performance after upgrades

Validation cost changes with the validator version, the loaded IG packages and the terminology checks it performs. A release that is faster for one profile can be slower for another, and a slower write path can surface first as timeouts or queued requests. Record request latency for create and update calls before and after each upgrade, and compare rejection rates to spot rules that changed behavior. Confirm the expected baseline with your own test data, since no general figure applies to every deployment.

Where to read the HAPI FHIR documentation

Before you settle on a request or repository validation design, read the HAPI FHIR security introduction closely, because HAPI FHIR does not ship a single security layer. It offers building blocks such as authentication interceptors, the AuthorizationInterceptor, consent and search narrowing interceptors, CORS support and BALP audit logging. Validation sits beside these controls, not inside them, so the security page tells you what access rules you must still build around any validation interceptor you enable. Use it to map which write paths need authorization checks and which interceptors run before or after validation on each request. Read it as the design reference for the controls you will need to confirm in your own environment.

Next, read the HAPI FHIR JPA server introduction to see how the JPA server handles resources it stores, the database behind it, and the terminology, validation and partitioning services that run on the server. This is where you confirm how stored resources reach the repository and which validation components the server exposes. Note which FHIR versions the server supports, since validation rules and profile behavior depend on the version you deploy. Also check the partitioning material if your data is split across tenants or regions, because validation settings may need to be consistent across partitions.

Finally, check the HAPI FHIR versions page for the Java requirement and the release line you plan to run. Validation behavior, interceptor names and configuration keys can change between releases, so confirm them against the exact version in your environment rather than against examples from older guides or blog posts. Record the version you test against, and repeat the validation tests whenever you upgrade. The pages above describe the product as documented, so treat any difference you observe in your own build as something to resolve with the release notes before you change production settings.

How DeployOpen delivers HAPI FHIR validation

DeployOpen plans, builds and documents the validation layer on a self-hosted HAPI FHIR JPA server inside your infrastructure. We agree which payloads are checked at the HTTP boundary, which stored data is checked in the repository, and how both are tested before go-live, so your compliance and engineering teams can review the same written design.

How we scope

  • Inventory the write paths, batch and transaction bundles, and bulk loads that reach the server
  • Agree which profiles and implementation guides apply to each resource type and each sending system
  • Record the latency budget for write requests and the expected volume of legacy data to review
  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts

How we build

  • Configure the request-side validation interceptor and the repository-side validation settings as separate, documented components
  • Load the required IG packages and validation support modules at versions pinned for each environment
  • Test rejected, accepted and legacy-invalid records against both layers, including batch requests
  • Measure write latency with and without each check and record the trade-off in the design document

How we hand over

  • Deliver the validation design, rule inventory and configuration with the reasons for each setting
  • Provide a test suite and sample payloads that your team can rerun after upgrades or profile changes
  • Document how to handle failed records, quarantine legacy data and report results to data senders
  • Walk your engineers through operations, including what a failed check looks like in logs and metrics

How we support

  • Retest validation behavior after each HAPI FHIR, IG package or Java runtime upgrade you plan
  • Review new profile versions and dependency changes before they reach production
  • Ongoing support, upgrades and continuous testing are available as a retainer, with terms agreed in writing
  • Confirm with your security and compliance leads which evidence they need from validation controls

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.