Skip to content

Treat a blank edition in a permanent link as no edition - #115

Merged
openipc-ai merged 1 commit into
masterfrom
permalink-blank-values
Aug 25, 2026
Merged

Treat a blank edition in a permanent link as no edition#115
openipc-ai merged 1 commit into
masterfrom
permalink-blank-values

Conversation

@openipc-ai

Copy link
Copy Markdown
Collaborator

Regression from #114, found while triaging website bugs filed against
OpenIPC/firmware.

A permanent link names every field whether or not it has a value. OpenIPC/firmware#1912
carries a real one:

https://openipc.org/cameras/vendors/sigmastar/socs/ssc338q?mac=…&rom=nand&var=&sd=sd

var= with nothing after it. The menu produces exactly that, because
allowedEditions falls back to '' for a chip with nothing published, and the
form then posts an empty edition.

if params[key] treats "" as an answer, so firmware_version became "" and
the dropdown rendered with nothing selected:

&var=      -> selected ["nor16m"]
&ver=      -> selected ["nor16m"]
&var=lite  -> selected ["nor16m", "lite"]

Before #114 this was unreachable — show read ver, which permalink never
wrote, so an empty var= was ignored and the lite constructor default stood.
Accepting var and emitting ver made both spellings live. Mine.

present? instead: blank in a query string means "not specified".

Severity

Low, and worth stating rather than overselling. checkFlashSize() runs on load,
'' is not in the allowed list, so JavaScript moves off it; and a browser
submits the first option of a select with nothing marked selected. So this never
produced wrong flashing instructions. It rendered a form the visitor had to
notice and correct, reached from a link the site generated itself.

Verification

bin/rails test — 200 runs, 756 assertions, 0 failures (198 before).
Reverting to bare truthiness fails both new tests. 21 rubocop offences in the
touched files, unchanged from master.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YFg9PRy2T6cr983S8gran5

Regression from #114, found while triaging website bugs filed against
OpenIPC/firmware. A permanent link names every field whether or not it
has a value, so `?...&rom=nor16m&var=&sd=sd` is what a link built from a
camera with no edition chosen looks like -- and the menu produces
exactly that, because allowedEditions falls back to '' for a chip with
nothing published. OpenIPC/firmware#1912 carries a real one.

`if params[key]` treats the empty string as an answer, so the edition
became "" and the dropdown rendered with nothing selected at all.
Before #114 this was unreachable: `show` read `ver`, which permalink
never wrote, so an empty `var=` was simply ignored. Accepting `var` --
and emitting `ver` -- made both spellings live.

`present?` instead. Blank in a query string means "not specified", so
the constructor default stands, which is what it did before.

JavaScript covers for it on load, since '' is not in the allowed list
and checkFlashSize moves off it, and a browser submits the first option
of a select with nothing marked. So this never produced wrong
instructions -- but it rendered a form the visitor had to notice and
correct, on a link the site generated itself.

Two tests, one per spelling. Reverting to bare truthiness fails both.
21 rubocop offences in the touched files, unchanged from master.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YFg9PRy2T6cr983S8gran5
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Ignore blank edition values in permanent links

🐞 Bug fix 🧪 Tests 🕐 Less than 10 minutes

Grey Divider

AI Description

• Ignore blank permalink values so camera defaults remain selected.
• Cover empty legacy var and current ver edition parameters.
Diagram

sequenceDiagram
  actor User
  participant Browser
  participant Controller as SoCs Controller
  participant Camera
  participant View
  User->>Browser: Open permanent link
  Browser->>Controller: GET with blank edition
  Controller->>Controller: Ignore blank value
  Controller->>Camera: Preserve edition default
  Camera-->>View: Default edition
  View-->>Browser: Render selected option
Loading
High-Level Assessment

Using present? at the shared permalink-field boundary is the appropriate approach because generated links represent missing values as empty strings across all mapped fields. Restricting the fix to edition keys would duplicate semantics and leave other blank permalink fields able to overwrite defaults.

Files changed (2) +34 / -1

Bug fix (1) +8 / -1
socs_controller.rbIgnore blank values while applying permalink fields +8/-1

Ignore blank values while applying permalink fields

• Changes permalink assignment to require a present parameter value instead of merely an existing key. Empty query values therefore leave constructor defaults, including the default firmware edition, intact.

app/controllers/cameras/socs_controller.rb

Tests (1) +26 / -0
socs_controller_test.rbCover blank legacy and current edition parameters +26/-0

Cover blank legacy and current edition parameters

• Adds a shared assertion helper and regression tests proving empty 'var=' and 'ver=' parameters preserve the Lite default selection. The tests cover both historical and current permalink spellings.

test/controllers/socs_controller_test.rb

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai
openipc-ai merged commit ef6941e into master Aug 25, 2026
2 checks passed
@openipc-ai
openipc-ai deleted the permalink-blank-values branch August 25, 2026 12:19
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.

1 participant