Skip to content

Conversation

@dracos
Copy link
Member

@dracos dracos commented Jan 15, 2026

[skip changelog]

@dracos dracos requested a review from chrismytton January 15, 2026 08:59
@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 86.40777% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.65%. Comparing base (66b20f1) to head (97249c3).

Files with missing lines Patch % Lines
perllib/FixMyStreet/App/Controller/Report/DVLA.pm 40.00% 9 Missing ⚠️
web/cobrands/fixmystreet-uk-councils/dvla.js 94.11% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5808      +/-   ##
==========================================
- Coverage   82.66%   82.65%   -0.01%     
==========================================
  Files         459      461       +2     
  Lines       35850    35953     +103     
  Branches     5854     5855       +1     
==========================================
+ Hits        29634    29716      +82     
- Misses       4510     4531      +21     
  Partials     1706     1706              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@chrismytton chrismytton left a comment

Choose a reason for hiding this comment

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

Looks good and works well! Just a few bits of feedback/questions.

sub lookup : Path : Args(0) {
my ($self, $c) = @_;

my $reg = $c->req->body_params->{registration};
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth doing any kind of input validation here, e.g. to check its alphanumeric? Guess the DVLA API does its own validation as well.

Comment on lines +23 to +31
my $response = $ua->post(
$dvla->{uri} . '/v1/vehicles',
X_API_Key => $dvla->{key},
Content_Type => 'application/json',
Content => encode_json($request),
);

$c->res->content_type('application/json; charset=utf-8');
$c->res->body($response->decoded_content);
Copy link
Member

Choose a reason for hiding this comment

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

I think this could do with some kind of error handling. Could either have it acting as a pure proxy, in which case we should be setting the status code on the response so that's passed through to the JS. Or alternatively we could add more complex error handling here on the server to handle 5xx and 4xx errors from the DVLA API and return a consistent "error" response to the JS.

if (!reg) return;
e.preventDefault();
e.stopPropagation();
$.post('/report/dvla', {'registration':reg}, function(data) {
Copy link
Member

Choose a reason for hiding this comment

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

Similarly here, could do with some error handling for when the DVLA controller returns an error status.

var type = data.typeApproval || '';
var wheelplan = data.wheelplan || '';
var vehicle_type = '';
if (type.match(/L[1-7]|motorcycle/i) || wheelplan.match(/motorcyle|moped|2 wheel/i)) {
Copy link
Member

Choose a reason for hiding this comment

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

Should motorcyle be motorcycle?

if (!yesno) return;
yesno = yesno.value;
if (!yesno) {
field = document.querySelector('input[name*="' + fields.reg + '"]');
Copy link
Member

Choose a reason for hiding this comment

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

Don't think field is declared anywhere?

if (data.fuelType) vehicle_desc += ', ' + data.fuelType;
if (data.yearOfManufacture) vehicle_desc += ', ' + data.yearOfManufacture;
var reason = 'We cannot accept reports on vehicles that ' + reasons.join(' or ');
$msg = $('<div class="js-stopper-notice box-warning"><strong>' + vehicle_desc + '</strong><br>' + reason + '. You may be able to <a href="https://contact.dvla.gov.uk/report-untaxed-vehicle">contact the DVLA</a>.</div>');
Copy link
Member

Choose a reason for hiding this comment

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

Don't think $msg is declared anywhere?

<input class="govuk-radios__input" id="dvla_reg_have_yes" name="dvla_reg_have" type="radio" value="1" data-show="#dvla_reg_field" required>
<label class="govuk-label govuk-radios__label" for="dvla_reg_have_yes">Yes</label>
</div>
<div id="dvla_reg_field" class="hidden-js govuk-radios__conditional govuk-radios__conditional--hidden" id="conditional-contact">
Copy link
Member

Choose a reason for hiding this comment

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

This <div> has two id attributes.

Comment on lines +140 to +143
<div class="floating-button-spacer"><div class="floating-button-wrapper"><div class="floating-button">
<div class="pre-button-messaging"></div>
<button class="btn btn--block btn--primary js-reporting-page--next">Continue</button>
</div></div></div>
Copy link
Member

Choose a reason for hiding this comment

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

Do we want some kind of loading indicator around here somewhere, to show that we're waiting for a response from an external API?

<div id="dvla_reg_field" class="hidden-js govuk-radios__conditional govuk-radios__conditional--hidden" id="conditional-contact">
<div class="govuk-form-group">
<label class="govuk-label" for="dvla_reg">Registration number</label>
<input class="govuk-input required" id="dvla_reg" name="dvla_reg" type="text" spellcheck="false">
Copy link
Member

Choose a reason for hiding this comment

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

When I was testing this I pressed return instead of clicking "Continue" and it submitted the whole form. So think we need to e.preventDefault somewhere along the line.

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.

3 participants